Hello [EMAIL PROTECTED]!

On 26-Ago-00, you wrote:

 g> See attached rebol file and output.

How about:

>> ideal-looper: func [
[    'element [word!]    
[    'index [word!]      
[    series [series!]    
[    code [block!]       
[    /local f
[    ] [
[    f: func reduce [element index] code
[    repeat i length? series [f series/:i i]
[    ]
>> ideal-looper char pos "hello" [print [pos char]]
1 h
2 e
3 l
4 l
5 o

Much simpler, isn't it? :-) You get a new context and the correct
bindings for free creating a function.

However, there really seems to be some problems with recursion and
REPEAT:

>> 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
6 none h e l l o
6 none h e l l o
6 none h e l l o
6 none h e l l o

But:

>> repeat i 10 [prin i repeat i 10 [prin " " prin i] prin newline]
1 1 2 3 4 5 6 7 8 9 10
2 1 2 3 4 5 6 7 8 9 10
3 1 2 3 4 5 6 7 8 9 10
4 1 2 3 4 5 6 7 8 9 10
5 1 2 3 4 5 6 7 8 9 10
6 1 2 3 4 5 6 7 8 9 10
7 1 2 3 4 5 6 7 8 9 10
8 1 2 3 4 5 6 7 8 9 10
9 1 2 3 4 5 6 7 8 9 10
10 1 2 3 4 5 6 7 8 9 10

which makes me wonder...

Anyway, using FOR:

>> 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

I'd suggest reporting that to feedback.

HTH,
    Gabriele.
-- 
Gabriele Santilli <[EMAIL PROTECTED]> - Amigan - REBOL programmer
Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/

Reply via email to