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 0:19

Hi all, two more cents to let Break work as usual: :-) use [insert-only break-return] [ insert-only: func [series value] [insert/only series value] break-return: func [value] [break/return 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." ][ result: reduce [:break-return any [make result result make block! 10]] reduce [ :loop 1 reduce [ :change result :first reduce [:break-return] :head pick reduce [:insert :insert-only] not only :tail :second result :do block :change result none ] :do result ] ] ] ex. probe repeat x 10 collectb [if x = 6 [break] x * 2] --- Ciao Romano