Hello,
Maybe instead of (repeat), there could be a generally useful from-to word:
: from-to ( to from quot -- )
from-to-done? [ from-to-done ] [ from-to-iterate from-to ] if ;
With helpers:
: from-to-done? ( n i quot -- n i quot ? ) pick pick <= ;
: from-to-done ( n i quot -- ) 3drop ;
: from-to-iterate ( n i quot -- n i quot ) dup >r call 1+ r> ;
Then repeat is:
: alt-repeat ( n quot -- ) 0 swap from-to ;
I haven't tested this but that's the idea.
Look at (repeat) :
: (repeat) ( from to quot -- )
pick pick >= [
3drop
] [
[ swap >r call 1+ r> ] keep (repeat)
] if ; inline
Notice that from-to is almost the same thing, except the pieces are named. You
get readability and maintain good performance.
Ed
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk