[REBOL] collect-in
From: rotenca::telvia::it at: 11-Dec-2003 15:36
This is my idea of collect:
collect-in: func [
{Append block evaluations to a series, use as body in For, Repeat, etc.}
dest [block! hash! list! any-string!] "Series to append results"
block [block!] "Block to evaluate."
/only "Inserts into dest using the Only refinement."
/local main
][
change/only change change second main: func [res [any-type!]][
none none none get/any 'res
get/any 'res
] pick [insert insert/only] not only 'tail dest
reduce [:main to-paren block]
]
;Usage:
dest: make block! 100
repeat n 10 collect-in dest [n * 100]
The advantages:
is trasparent for break
works with empty block
inside the body you know where values are stored
is not slow
I should like to submit it the view 1.3 project
What do you think?
---
Ciao
Romano