count ( ... seq quot: ( ... elt -- ... ? ) -- ... n )
Factor handbook » The language » Collections » Sequence operations » Sequence combinators

Prev:partition ( ... seq quot: ( ... elt -- ... ? ) -- ... trueseq falseseq )
Next:minimum ( seq -- elt )


Vocabulary
sequences

Inputs
seqa sequence
quota quotation


Outputs
nan integer


Word description
Efficiently returns the number of elements that the predicate quotation matches.

Examples
USING: math ranges sequences prettyprint ; 100 [1..b] [ even? ] count .
50


Definition


: count ( ... seq quot: ( ... elt -- ... ? ) -- ... n )
[ 1 0 ? ] compose map-sum ; inline