Handbook
Glossary
slice-when ( seq quot: ( elt -- ? ) -- seq' )
Vocabulary
sequences
.
extras
Inputs
seq
a
sequence
quot
a
quotation
Outputs
seq'
a
sequence
Definition
USING:
kernel
math
sequences
;
IN:
sequences.extras
::
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