last ( seq -- elt )
Factor documentation > Factor handbook > The language > Collections > Sequence operations > Accessing sequence elements
Prev:?second ( seq -- elt/f )
Next:?last ( seq -- elt/f )


Vocabulary
sequences

Inputs and outputs
seqa sequence
eltan object


Word description
Outputs the last element of a sequence.

Errors
Throws an error if the sequence is empty.

Definition
USING: kernel math ;

IN: sequences

: last ( seq -- elt ) [ length 1 - ] [ nth ] bi ;