Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: REBOL Enhancement Proposals (REPs)

From: al:bri:xtra at: 28-Sep-2001 5:32

Joel wrote:
> Given a block of numbers, what's the simplest way in REBOL to write a
smoothing operation that averages each interior value (i.e., all but the first and last) with the two values on either side of it? >> I think this approach gives the correct result:
>> b: [1 2 3 4 5 6 7 8 9 10]
== [1 2 3 4 5 6 7 8 9 10]
>> c: []
== []
>> i: b
== [1 2 3 4 5 6 7 8 9 10]
>> forall i [t: copy/part i 3 if 3 = length? t [append/only c t]]
== []
>> c
== [[1 2 3] [2 3 4] [3 4 5] [4 5 6] [5 6 7] [6 7 8] [7 8 9] [8 9 10]]
>> map c func [t][(t/1 + t/2 + t/3) / 3]
== [2 3 4 5 6 7 8 9] Andrew Martin ICQ: 26227169 http://zen.scripterz.org