Accessing sequence elements

Factor handbook » The language » Collections » Sequence operations

Factor handbook » The language » Collections » Sequence operations

Prev: | The f object as a sequence |

Next: | Sequence combinators |

Element access by index, without raising exceptions:

Concise way of extracting one of the first four elements:

Extracting the last element:

Unpacking sequences:

See also

nth

?nth ( n seq -- elt/f )

Concise way of extracting one of the first four elements:

first ( seq -- first )

second ( seq -- second )

third ( seq -- third )

fourth ( seq -- fourth )

?first ( seq -- elt/f )

?second ( seq -- elt/f )

Extracting the last element:

last ( seq -- elt )

?last ( seq -- elt/f )

Unpacking sequences:

first2 ( seq -- first second )

first3 ( seq -- first second third )

first4 ( seq -- first second third fourth )

See also

nth