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

[REBOL] Re: collect-in

From: rotenca:telvia:it at: 13-Dec-2003 14:30

Hi Ladislav,
> >The advantages: > > is trasparent for break > > works with empty block > > inside the body you know where values are stored > > is not slow > Does this behave well w.r.t. Return?
Should be trasparent for return. Also the value returned by the loop is the same. The body block is executed in the original environment, only it is copied by to paren! paren! is not supported for dest series. Follow a more readable version: collect-in: func [ {Append block evaluations to a series, use as body in For, Repeat, etc.} dest [block! hash! list! any-string!] "Series to append results" block [block!] "Block to evaluate." /only "Inserts values into dest using /only." /local main ][ insert second main: func [res [any-type!]][get/any 'res -1] reduce [ 'pick pick [insert insert/only] not only 'tail dest ] reduce [:main to-paren block] ] --- Ciao Romano