[REBOL] Re: [COLLECT] COLLECT function/Examples?
From: tim-johnsons::web::com at: 12-May-2006 15:39
* Gregg Irwin <greggirwin-mindspring.com> [060512 15:27]:
> Hi Tim,
>
> TJ> I'm seeing something strange on my system:
> TJ> It appears that [throw] is suppressing the docstring.
> TJ> Remove it or replace with [catch] and the docstring is enabled.
>
> TJ> Are you getting the same?
>
> Yes. I've seen this before. Putting the func attributes after the doc
> string works as well. New version below. Thanks for "catching" that!
Got it.
Thanks
> -- Gregg
>
> collect: func [
> {Collects values, returning them as a series.}
> [throw]
> 'emit [word!] "Word used to collect values"
> block [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]
> use [dst ins] copy/deep [
> ; copy/deep lets us use just [] as the fallback value here.
> dst: any [:dest []]
> ; make the function used to collect values.
> ins: either only [[insert/only]] [[insert]]
> set emit func [value [any-type!]] compose [
> (ins) tail :dst get/any 'value
> get/any 'value
> ]
> do bind/copy block emit
> head :dst
> ]
> ]
>
> --
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
--
Tim Johnson <tim-johnsons-web.com>
http://www.alaska-internet-solutions.com