split-when ( ... seq quot: ( ... elt -- ... ? ) -- ... pieces )
Factor handbook » The language » Collections » Sequence operations » Splitting sequences

Prev:split-slice ( seq separators -- pieces )
Next:split-when-slice ( ... seq quot: ( ... elt -- ... ? ) -- ... pieces )


Vocabulary
splitting

Inputs
seqa sequence
quota quotation with stack effect ( ... elt -- ... ? )


Outputs
piecesa new array


Word description
Splits seq at each occurrence of an element for which quot gives a true output and outputs an array of pieces. The pieces do not include the elements along which the sequence was split.

Examples
USING: ascii kernel prettyprint splitting ; "hello,world-how.are:you" [ letter? not ] split-when .
{ "hello" "world" "how" "are" "you" }


Definition


: split-when
( ... seq quot: ( ... elt -- ... ? ) -- ... pieces )
[ subseq-unsafe ] (split) ; inline