Alex, Except for the constructor and last word, our two datastructures are very similar. Mind if I take your implementation and split it off into a separate library, adding a couple of utility functions that I need? Dan
On 1/13/07, Alex Chapman <[EMAIL PROTECTED]> wrote: > I implemented something similar when I wrote libs/gap-buffer. It's called > 'circular' and wraps an underlying sequence, allowing indexing to start from > any point in the sequence and wrap around. > > TUPLE: circular start ; > > C: circular ( seq -- circular ) > 0 over set-circular-start [ set-delegate ] keep ; > > : circular@ ( n circular -- n seq ) > [ tuck circular-start + swap length mod ] keep delegate ; > > M: circular nth ( n seq -- elt ) bounds-check circular@ nth ; > > M: circular nth-unsafe ( n seq -- elt ) circular@ nth-unsafe ; > > M: circular set-nth ( elt n seq -- ) bounds-check circular@ set-nth ; > > M: circular set-nth-unsafe ( elt n seq -- ) circular@ set-nth-unsafe ; > > : change-circular-start ( n circular -- ) > #! change start to (start + n) mod length > [ circular@ drop ] keep set-circular-start ; > > > I'm not sure what the problem you're encountering is, but maybe this will > help you work it out. > > Alex > > > On 1/13/07, Daniel Ehrenberg <[EMAIL PROTECTED]> wrote: > > > > Hi all > > > > I'm trying to implement a particular datastructure in Factor for XML > > parsing. It's sorta like a circular list. The code is at > > http://paste.lisp.org/display/35077 . For some reason, it > works when I > > use things like length, nth and set-nth, but >string and sequence= > > don't work, complaining that there is no length method. Strangely, > > each and map still do work. Do you have any ideas for how to fix this > > or what the problem is? Chris thought it might be something related to > > delegation, but that isn't true, because no delegation is used. He > > said that the code actually works if you step through nth-unsafe in > > the walker. Is there an error in what I've written, or possibly in the > > implementation of generic words? > > > > Dan > > > > > ------------------------------------------------------------------------- > > Take Surveys. Earn Cash. Influence the Future of IT > > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > > opinions on IT & business topics through brief surveys - and earn cash > > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > > Factor-talk mailing list > > [email protected] > > https://lists.sourceforge.net/lists/listinfo/factor-talk > > > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > Factor-talk mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/factor-talk > > > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
