Collect

angerangel edited this page Jan 2, 2013 · 1 revision

Table of Contents

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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.