Handbook
Glossary
trim ( ... seq quot: ( ... elt -- ... ? ) -- ... newseq )
Factor handbook
»
The language
»
Collections
»
Sequence operations
»
Trimming sequences
Next:
trim-head ( ... seq quot: ( ... elt -- ... ? ) -- ... newseq )
Vocabulary
sequences
Inputs
seq
a
sequence
quot
a
quotation
Outputs
newseq
a
sequence
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 new sequence.
Examples
USING: prettyprint math sequences ; { 0 0 1 2 3 0 0 } [ zero? ] trim .
{ 1 2 3 }
See also
trim-slice
,
trim-head
,
trim-head-slice
,
trim-tail
,
trim-tail-slice
Definition
USING:
kernel
;
IN:
sequences
:
trim
( ... seq quot: ( ... elt -- ... ? ) -- ... newseq )
[
trim-slice
]
[
drop
]
2bi
like
;
inline