filter! ( ... seq quot: ( ... elt -- ... ? ) -- ... seq )
Factor handbook » The language » Collections » Sequence operations » Destructive sequence operations

Prev:delete-all ( seq -- )
Next:suffix! ( seq elt -- seq )


Vocabulary
sequences

Inputs
seqa resizable mutable sequence
quota quotation with stack effect ( ... elt -- ... ? )


Outputs
seqa resizable mutable sequence


Word description
Applies the quotation to each element in turn, and removes elements for which the quotation outputs a false value.

Notes
The sequence seq MUST be growable. See Resizable sequence implementation.

Side effects
Modifies seq

Examples
Remove the odd numbers
USING: kernel math prettyprint sequences ; V{ 1 2 3 4 5 6 7 8 9 0 } [ odd? not ] filter! .
V{ 2 4 6 8 0 }


See also
filter, filter-as, reject, reject-as, reject!, sift, harvest

Definition


: filter! ( ... seq quot: ( ... elt -- ... ? ) -- ... seq )
[ 0 0 ] 2dip filter-from! ; inline