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
]
>1 h h e l l o
>2 e h e l l o
>3 l h e l l o
>4 l h e l l o
>5 o h e l l o
>
>
>HTH,
> Gabriele.