The thing is, (repeat) is used directly by growable.contract, so it needs to either remain in a form that contains both a start and end number. Also, this counts down, rather than up, which would break everything. So if you want to write a new repeat, it should basically be (repeat) but factored well (if you still think it needs it). Though I may be wrong.
Dan On 7/3/07, Eduardo Cavazos <[EMAIL PROTECTED]> wrote: > Hello, > > Here's the current implementation of repeat: > > ---------------------------------------------------------------------- > > : (repeat) ( from to quot -- ) > pick pick >= [ > 3drop > ] [ > [ swap >r call 1+ r> ] keep (repeat) > ] if ; inline > > : repeat ( n quot -- ) 0 -rot (repeat) ; inline > > ---------------------------------------------------------------------- > > To understand how repeat works, you really have to work through what > (repeat) is doing. Here's an alternative version which is "self > documenting" and is just as fast: > > : alt-repeat ( n quot -- ) > repeat-done? [ repeat-done ] [ repeat-iterate alt-repeat ] if ; > > The helper words are: > > ---------------------------------------------------------------------- > > : repeat-done? ( n quot -- n quot ? ) over 0 = ; > > : repeat-done ( n quot -- ) 2drop ; > > : repeat-iterate ( n quot -- n quot ) dup >r call 1- r> ; > > ---------------------------------------------------------------------- > > Again, in this style of design, all the stack shuffling is > factored out into helper words. > > It's true that in this alternate version there are more words. But, > according to masters of the art of stack programming, more and smaller > words are better than less and longer words. So, I'm going with that > principle here. > > 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 > ------------------------------------------------------------------------- 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
