Accessing sequence elements
Factor handbook » The language » Collections » Sequence operations

Prev:The f object as a sequence
Next:Sequence combinators


Element access by index, without raising exceptions:
?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 )

last2 ( seq -- penultimate ultimate )


See also
nth