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: 27-Nov-2003 15:12

Hi, all this works also with foreach (not only with loop and repeat): use [insert-only break-return res] [ insert-only: func [series value] [insert/only series value] break-return: func [value] [break/return value] res: func [value] [func [] reduce [value]] collectB: func [ {Collects block evaluations, use as body in For, Repeat, etc.} block [block!] "Block to evaluate." /initial result [series!] "Initialize the result." /only "Inserts into result using the Only refinement." ][ initial: res reduce [none any [make result result make block! 10]] reduce [ :loop 1 reduce [ :change :initial reduce [:break-return] pick reduce [:insert :insert-only] not only :tail :second :initial :do block ;:do block could be to-paren block, to make it a little more fast ; but so the block is copyed :change :initial none ] :do :initial ] ] ] --- Ciao Romano