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

Prev:unclip-last-slice ( seq -- butlast-slice last )
Next:replace-slice ( new from to seq -- seq' )


Inputs and outputs
seqa sequence
na non-negative integer
before-slicea sequence
after-slicea slice

Word description
Outputs a pair of sequences, where before consists of the first n elements of seq and has the same type, while after is a slice of the remaining elements.

Unlike cut, the run time of this word is proportional to the length of before, not after, so it is suitable for use in an iterative algorithm which cuts successive pieces off a sequence.

See also
cut, cut*


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