VocabularysequencesInputs and outputs| quot | a quotation with stack effect ( ... elt -- ... ? ) |
| selector | a quotation with stack effect ( ... elt -- ... ) |
| accum | a vector |
Word descriptionCreates a new vector to accumulate the values which return true for a predicate. Returns a new quotation which accepts an object to be tested and stored in the collector if the test yields true. The collector is left on the stack for convenience.
Examples! Find all the even numbers:
USING: prettyprint sequences math kernel ;
10 iota [ even? ] selector [ each ] dip .
V{ 0 2 4 6 8 }
NotesUsed to implement the
filter word. Compare this word with
collector, which is an unfiltering version.
Definition