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

[REBOL] A surprise from REPEAT

From: larry:ecotope at: 1-Aug-2001 19:56

Hi all, I just got a surprise from the REPEAT function. We all use it in the standard form of
>> blk: [x y z]
== [x y z]
>> repeat j length? blk [print j]
1 2 3 where the second argument to REPEAT is the number of repetitions, and j iterates from 1 to that number. Well I inadvertently left LENGTH? out of my statement and got this instead
>> repeat j blk [print j]
x y z So REPEAT has the same capability as FOREACH to access each item of a series. I don't recall seeing this documented anywhere, so I thought I would mention it here. It sure surprised me!! -Larry