Gregg Irwin napsal(a):
> Ladislav,
>
> Thanks for the comments and catching the 'yield reference I missed in
> the doc string.
>   
...snip...

if we favour readability, then this one may be preferable, the speed 
difference looks negligible

    collect: func [
        [throw]
        {Collects values, returning them as a block.}
        'emit "Word used to collect values"
        block [any-block!] "Block to evaluate"
        /into dest [series!] "Where to append results"
        /only "Insert series values as series"
    ] [
        ; Create a new context containing just one word (the EMIT
        ; argument) and set the 'emit word to refer to the new context
        ; word. Note the care taken to suppress possible conflicts and
        ; undesired evaluations.
        emit: reduce [emit]
        emit: first use emit reduce [emit]
        only: either only [[insert/only]] [[insert]]
        use [dst] copy/deep [
            ; copy/deep lets us use just as the fallback value [] here.
            dst: any [:dest []]
            set emit func [value [any-type!]] compose [
                (only) tail :dst get/any 'value
                get/any 'value
            ]
            do bind/copy block emit
            head :dst
        ]
    ]


-L
-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to