Handbook
Glossary
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
seq
a
sequence
quot
a
quotation
Outputs
n
an
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
USING:
kernel
;
IN:
sequences
:
count
( ... seq quot: ( ... elt -- ... ? ) -- ... n )
[
1 0
?
]
compose
map-sum
;
inline