split1 ( seq subseq -- before after )
Factor handbook » The language » Collections » Sequence operations » Splitting sequences

Prev:?tail-slice ( seq end -- newseq ? )
Next:split1-slice ( seq subseq -- before-slice after-slice )


Vocabulary
splitting

Inputs
seqa sequence
subseqa sequence


Outputs
beforea new sequence
aftera new sequence


Word description
Splits seq at the first occurrence of subseq, and outputs the pieces before and after the split. If subseq does not occur in seq, then before is just seq and after is f.

See also
split1-slice, split1-last, split1-last-slice

Definition


: split1 ( seq subseq -- before after )
[ subseq-range ] keepd ?snip ; inline