Handbook
Glossary
split1-last ( seq subseq -- before after )
Factor handbook
»
The language
»
Collections
»
Sequence operations
»
Splitting sequences
Prev:
split1-when-slice ( ... seq quot: ( ... elt -- ... ? ) -- ... before-slice after-slice )
Next:
split1-last-slice ( seq subseq -- before-slice after-slice )
Vocabulary
splitting
Inputs
seq
a
sequence
subseq
a
sequence
Outputs
before
a new sequence
after
a new sequence
Word description
Splits
seq
at the last 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
,
split1-slice
,
split1-last-slice
Definition
USING:
kernel
sequences
;
IN:
splitting
:
split1-last
( seq subseq -- before after )
[
<reversed>
]
bi@
split1
[
reverse
]
bi@
dup
[
swap
]
when
;