Hi Ed, Here are some words from your cursor vocab. They're using your new stack effects:
: curr ( cursor -- elt ) [ seq>> ] [ i>> ] bi nth ; : set-curr ( cursor val -- cursor ) >r dup [ seq>> ] [ i>> ] bi r> set-nth drop ; : eval! ( cursor -- cursor ) dup >r eval r> swap set-curr ; Now let's try using the current stack effects: : curr ( cursor -- elt ) [ i>> ] [ seq>> ] bi nth ; : set-curr ( val cursor -- cursor ) [ [ i>> ] [ seq>> ] bi set-nth ] keep ; : eval! ( cursor -- cursor ) dup >r eval r> set-curr ; Much simpler huh? Slava On Mar 30, 2008, at 2:42 PM, Eduardo Cavazos wrote: > Hello, > > Here's another experiment in cursor implementation: > > http://dharmatech.onigirihouse.com/cursor/cursor.factor > > Some combinators in terms of that vocab: > > http://dharmatech.onigirihouse.com/cursor/combinators/combinators.factor > > The basic operations on the cursor are: > > beg? end? prev next curr > > You can get the "index" with 'i>>'. > > There's an "extended" cursor called eval-cursor with a slot for a > quotation. > An 'eval' word can be used to evaluate the cursor's quotation on the > current > value. > > The subset-cursor is an extention of an eval-cursor; it has a slot > for the > accumulation vector. It's used to implement... subset. > > The symmetry of (each), (map), (subset), and (position) is nice. > Well, I sort > of shoehorned (position) in there. :-) > > One point here is that with the right cursor abstraction, 'each' and > 'map' are > both two-liners. > > Ed > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > _______________________________________________ > Factor-talk mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/factor-talk ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
