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

[REBOL] Re: Combinations of things (small puzzler)

From: lmecir:mbox:vol:cz at: 22-Oct-2001 22:13

Aha, ...skip...
> The issue I was asking about was not the fact that REPEAT has an > effect on its third argument, but that its behavior is different > depending on the type of the second argument. > > -jn- > > -- > "This sentence contradicts itself -- no actually it doesn't." > -- Doug Hofstadter > joel<dot>neely<at>fedex<dot>com
That is not correct, the behaviour of REPEAT is exactly the same - REPEAT modifies its second argument. The difference in your code was, that 'item in the case of (repeat item [1 2 3] [...]) did not have the same responsibility as 'i in the case of (repeat i 3 [...]). Here is a code that can show some similarity: recursive: func [x] [ repeat i x [ if x = 1 [ print ["X:" x "I before recursive call: " i] recursive 2 print ["X:" x "I after recursive call: " i] ] ] ] recursive 1
>> recursive 1
X: 1 I before recursive call: 1 X: 1 I after recursive call: 3 blk-recursive: func [x] [ repeat i x [ if (length? x) = 1 [ print ["X:" mold x "I before recursive call: " i] blk-recursive [1 2] print ["X:" mold x "I after recursive call: " i] ] ] ] blk-recursive [1]
>> blk-recursive [1]
X: [1] I before recursive call: 1 X: [1] I after recursive call: 2 Cheers Ladislav