[REBOL] Rolling your own ideal looper: does Repeat still have a bug? Re:(2)
From: galtbarber:mailandnews at: 28-Aug-2000 12:47
Hi, Gabriele,
Your version is much nicer and cleaner and
probably runs just as fast or faster than mine, too.
That's what I was looking for, but you see things clearer!!
Anyway, thanks for your insights, I will take that
lesson to heart. By the way, do you know how Rebol itself
does foreach internally? Do they use a function
like you did, or is it done some other way?
Your example shows how arriving at the simple solution
may be a bit harder but well worth it!
I will send a note to feedback about the problem with 'repeat
-Galt
Here is Gabriele's lovely version:
---------------------------
ideal-looper: func [
'element [word!]
'index [word!]
series [series!]
code [block!]
/local f
] [
f: func reduce [element index] code
for i 1 length? series 1 [f series/:i i]
]
>>ideal-looper char pos s: "hello" [
prin [pos char]
ideal-looper char pos s [prin " " prin char]
prin newline
]