Rebol 编程/collect
外观
< Rebol 编程
COLLECT body /into output
评估一个代码块,通过 KEEP 函数存储值,并返回收集到的值的代码块。
COLLECT 是一个函数值。
- body -- 要评估的代码块(类型:代码块)
- /into -- 插入到缓冲区中(返回插入后的位置)
- output -- 缓冲区系列(已修改)(类型:系列)
collect: func [
{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 make function! [keep] copy/deep body make function! [value /only] copy/deep [
output: either only [insert/only output :value] [insert output :value]
:value
]
either into [output] [head output]
]