REBOL [ title: "collect" file: %collect.r author: "Brett Handley" email: brett@codeconscious.com web: http://www.codeconscious.com date: 24-Jul-2003 purpose: "Accumulate a repeated expression.." ] collect: func [ {Collects block evaluations, use as body in For, Repeat, etc.} block [block!] "Block to evaluate." /initial result [series! datatype!] "Initialise the result." /only "Inserts into result using Only refinement." ] [ if not initial [result: block!] result: any [all [datatype? result make result 1000] result] reduce ['head pick [insert insert/only] not only 'tail result to paren! block] ] comment [ for i 1 10 2 collect [i * 10] foreach [a b] [1 2 3 4] collect [a + b] foreach w [a b c d] collect [w] repeat e [a b c %.txt] collect/initial [e] %file iota: func [n [integer!]][repeat i n collect/initial [i] make block! n] iota 10 ]