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

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


Vocabulary
sequences

Inputs
seqa sequence
quota quotation


Outputs
newseqa sequence


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


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

Definition


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