How about this? : move-core-to-end ( seq -- seq ) [ length 2 - [1,b] ] keep [ swap move-to-end ] reduce ;
Though I feel like there's probably a more direct way to do this than moving each element in turn. - Jesse On 25-Feb-09, at 4:30 AM, Jon Kleiser wrote: > Here's follow-up to my first question about how to move the nth > element > to the end, which Daniel and Slava had several solutions for. > > On 2/23/09 7:19 PM, Daniel Ehrenberg wrote: >> Well, here's an inefficient way to do it, but the code is pretty: >> >> : move-to-end ( n seq -- newseq ) >> [ remove-nth ] [ nth ] 2bi suffix ; > > I now wanted to apply that operation for n=1 to n=length-2, i.e. > skipping the first (0) and last (length-1) index. I came up with the > following solution, but I suspect Daniel, Slava, or other Factor heads > on this list, may have a better (looking) way of doing it, maybe > without > the variable. Here's mine: > > : move-core-to-end ( seq -- seq ) > SYMBOL: target > dup > target set > length 2 - [1,b] [ target get move-to-end target set ] each > target get ; > > /Jon > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San > Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the > Enterprise > -Strategies to boost innovation and cut costs with open source > participation > -Receive a $600 discount off the registration fee with the source > code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > Factor-talk mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/factor-talk ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
