nth ( n seq -- elt )
Factor handbook » The language » Collections » Sequence operations » Sequence protocol

Prev:length ( seq -- n )
Next:nth-unsafe ( n seq -- elt )


Vocabulary
sequences

Inputs
na non-negative integer
seqa sequence


Outputs
eltthe element at the nth index


Generic word contract
Outputs the nth element of the sequence. Elements are numbered from zero, so the last element has an index one less than the length of the sequence. All sequences support this operation.

Errors
Throws a bounds-error if the index is negative, or greater than or equal to the length of the sequence.

Examples
USING: prettyprint sequences ; 1 { "a" "b" "c" } nth .
"b"


See also
?nth

Definition


Methods