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

[REBOL] Re: COLLECTing results

From: rotenca:telvia:it at: 24-Jul-2003 14:52

Hi Brett,
> Don't you just hate it when after testing, trying some more and some more > testing you press Send and then test think "Oh no!". The last version worked > for Repeat but not for Foreach - and I still don't know why. This one seems > to work however.
Foreach makes copy/deep on the body block to recurse well (repeat does not make it)
> collect: func [ > {Collects block evaluations, use as body in For, Repeat, etc.} > block [block!] "Block to evaluate." > /init result "Initialise the result series." > /only "Inserts into result using Only refinement." > ] [ > result: any [result make block! 100] > reduce [ > 'head pick [insert insert/only] not only 'tail result to paren! > block > ] > ]
this can also be: reduce ['head pick [insert insert/only] not only 'tail result do block] with a small change it can handle also paren! init value under last betas: reduce ['head pick [insert insert/only] not only 'tail 'first reduce [:result] do block] --- Ciao Romano