trim-head ( ... seq quot: ( ... elt -- ... ? ) -- ... newseq )
Factor handbook » The language » Collections » Sequence operations » Trimming sequences

Prev:trim ( ... seq quot: ( ... elt -- ... ? ) -- ... newseq )
Next:trim-tail ( ... seq quot: ( ... elt -- ... ? ) -- ... newseq )


Vocabulary
sequences

Inputs
seqa sequence
quota quotation


Outputs
newseqa sequence


Word description
Removes elements starting from the left side 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-head .
{ 1 2 3 0 0 }


See also
trim, trim-slice, trim-head-slice, trim-tail, trim-tail-slice

Definition


: trim-head
( ... seq quot: ( ... elt -- ... ? ) -- ... newseq )
(trim-head) tail ; inline