[REBOL] Re: COLLECTing results
From: lmecir:mbox:vol:cz at: 26-Nov-2003 10:55
Hi Brett, Andrew, Romano et al.,
>---latest version
>
>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 'do
>:block]
>]
>
I am sorry I missed your contribution on the subject somehow. I like it.
My two cents changing the behaviour of the function in cases like:
foreach head heads [...]
foreach insert inserts [...]
foreach tail tails [...]
foreach do does [...]
use [insert-only] [
insert-only: func [series value] [insert/only series value]
collect: func [
{Collects block evaluations, use as body in For, Repeat, etc.}
block [block!] "Block to evaluate."
/initial result [series!] "Initialise the result."
/only "Inserts into result using the Only refinement."
] [
result: any [make result result make block! 10]
reduce [
:head pick reduce [
:insert :insert-only
] not only :tail result :do block
]
]
]
-L