Hi Tim,

TJ> I've tried using this, but am unsure how. Can you give some
TJ> examples?

>> b: [1 2 3 4 5 6 7 8 9 10]
== [1 2 3 4 5 6 7 8 9 10]
>> collect n [foreach [x y] b [n add x y]]
== [3 7 11 15 19]

COLLECT returns a block. The word you give it is the "collector
function"; wherever that word appears in the block, a value will be
collected.

It's main goal is to eliminate tedious code. e.g.

fn: func [/local res] [
    res: copy []
    foreach ... [append res value]
    res
]

becomes:

fn: does [collect [foreach val ... [val value]]

Does that make sense?

-- Gregg                         

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

Reply via email to