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

[REBOL] Re: foreach with block question

From: joel:neely:fedex at: 13-Oct-2001 17:06

Hi, Miquel, Miquel Gaya wrote:
> but if I want generalize the foreach expression... > > >> row: [ a b c d e ] > == [a b c d e] > >> foreach row data [ print row ] > 1 > AAA > BBB
...
> DDD > VVV > 2 > 1 > >> > > row is considered a word, not a block. > How can I use foreach with a block ? >
Depending on what you want to do inside the repeated block...
>> rowlength: 5
== 5
>> s: data
== [1 AAA BBB 3 0 2 MMM XXX 1 1 3 DDD VVV 2 1]
>> forskip s rowlength [print [copy/part s rowlength]]
1 AAA BBB 3 0 2 MMM XXX 1 1 3 DDD VVV 2 1 == false -jn- -- ; sub REBOL {}; sub head ($) {@_[0]} REBOL [] # despam: func [e] [replace replace/all e ":" "." "#" "@"] ; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"} print head reverse despam "moc:xedef#yleen:leoj" ;