slice-when ( seq quot: ( elt -- ? ) -- seq' )


Vocabulary
sequences.extras

Inputs
seqa sequence
quota quotation


Outputs
seq'a sequence


Definition


:: slice-when ( seq quot: ( elt -- ? ) -- seq' )
seq length :> len 0
[ len dupd < ] [
dup seq quot find-from drop
[ 2dup = [ 1 + ] when ] [ len ] if* [ seq <slice> ] keep
len or swap
] produce nip ; inline