cut ( seq n -- before after )
Factor handbook » The language » Collections » Sequence operations » Subsequences and slices

Prev:unclip-last ( seq -- butlast last )
Next:cut* ( seq n -- before after )


Vocabulary
sequences

Inputs
seqa sequence
na non-negative integer


Outputs
beforea sequence
aftera sequence


Word description
Outputs a pair of sequences, where before consists of the first n elements of seq, while after holds the remaining elements. Both output sequences have the same type as seq.

Notes
Since this word copies the entire tail of the sequence, it should not be used in a loop. If this is important, consider using cut-slice instead, since it returns a slice for the tail instead of copying.

See also
cut*, cut-slice, cut-slice*

Definition


: cut ( seq n -- before after ) [ head ] [ tail ] 2bi ;