Handbook
Glossary
trim-slice ( ... seq quot: ( ... elt -- ... ? ) -- ... slice )
Factor handbook
»
The language
»
Collections
»
Sequence operations
»
Trimming sequences
Prev:
trim-tail ( ... seq quot: ( ... elt -- ... ? ) -- ... newseq )
Next:
trim-head-slice ( ... seq quot: ( ... elt -- ... ? ) -- ... slice )
Vocabulary
sequences
Inputs
seq
a
sequence
quot
a
quotation
Outputs
slice
a
slice
Word description
Removes elements starting from the left and right sides of a sequence if they match a predicate. Once an element does not match, the test stops and the rest of the sequence is left on the stack as a slice.
Examples
USING: prettyprint math sequences ; { 0 0 1 2 3 0 0 } [ zero? ] trim-slice .
T{ slice { from 2 } { to 5 } { seq { 0 0 1 2 3 0 0 } } }
See also
trim
,
trim-head
,
trim-head-slice
,
trim-tail
,
trim-tail-slice
Definition
USING:
kernel
;
IN:
sequences
:
trim-slice
( ... seq quot: ( ... elt -- ... ? ) -- ... slice )
[
trim-head-slice
]
[
trim-tail-slice
]
bi
;
inline