tail* ( seq n -- tailseq )
Factor handbook > The language > Collections > Sequence operations > Subsequences and slices

Prev:head* ( seq n -- headseq )
Next:rest ( seq -- tailseq )


Vocabulary
sequences

Inputs and outputs
seqa sequence
na non-negative integer
tailseqa new sequence


Word description
Outputs a new sequence consisting of the last n elements of the input sequence.

Examples
USING: sequences prettyprint ; { 1 2 3 4 5 6 7 } 2 tail* .
{ 6 7 }

When a sequence may not have enough elements:
USING: sequences prettyprint ; { 1 2 } 5 short tail* .
{ 1 2 }


Errors
Throws an error if the index is out of bounds.

See also
tail, tail-slice, tail-slice*

Definition