On Sat, Sep 26, 2009 at 8:44 PM, Hugh Aguilar <[email protected]> wrote:
> For example, I want to find a node in the list and split the list into two
> lists at that point. With sequences, the function find returns an index into
> the sequence. None of the spliting functions take an index however. All of
> them are splitting on a particular subsequence.

You can use cut and cut* to split a sequence at an index from the start or end:

http://docs.factorcode.org/content/word-cut%2Csequences.html
http://docs.factorcode.org/content/word-cut__star__%2Csequences.html

More generally, there is a whole set of words for slicing sequences;

http://docs.factorcode.org/content/article-sequences-slices.html

> Also, sometimes I want to insert a list into the middle of another list at a
> certain point. This is easily done with my insert function. The problems
> with inserting into sequences are very similar to the problems with
> splitting sequences. Also, sometimes I want to remove a portion of a list
> from a list. This is also cumbersome with sequences.

There is a word insert-nth that inserts a value at an index:

http://docs.factorcode.org/content/word-insert-nth%2Csequences.html

To insert a sequence at a subrange, use replace-slice:

http://docs.factorcode.org/content/word-replace-slice%2Csequences.html

> Sequences are nice because they can be written as literals in the
> source-code using the curly brackets. Also, they print out in a nice visual
> manner, whereas my lists are a big unreadable mess.

You can define literals and a printed representation for your own lists, too.

Slava

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to