Skip to content
angerangel edited this page Mar 15, 2013 · 1 revision

USAGE

   COLLECT body /into output

DESCRIPTION

Evaluates a block, storing values via KEEP function, and returns block of collected values.

COLLECT is a function value.

ARGUMENTS

  • body -- Block to evaluate (block!)

REFINEMENTS

  • /into -- Insert into a buffer instead (returns position after insert)
    • output -- The buffer series (modified) (series!)

#SOURCE

collect: make function! [  [
    {Evaluates a block, storing values via KEEP function, and returns block of collected values.}
    body [block!] "Block to evaluate"
    /into {Insert into a buffer instead (returns position after insert)}
    output [series!] "The buffer series (modified)"
][
    unless output [output: make block! 16]
    do func [keep] body func [value [any-type!] /only] [
        output: apply :insert [output :value none none only]
        :value
    ]
    either into [output] [head output]
] ]

Clone this wiki locally