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' )


Vocabulary
sequences

Inputs
seqa sequence
na non-negative integer


Outputs
before-slicea slice
after-slicea slice


Word description
Outputs a pair of sequences, where before-slice is a slice of the first n elements of seq, while after-slice is a slice of the remaining elements.

Notes
Unlike cut, this is suitable for use in an iterative algorithm which cuts successive pieces off a sequence.

See also
cut, cut*, cut-slice*

Definition


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