count= ( ... seq quot: ( ... elt -- ... ? ) n -- ... ? )


Vocabulary
sequences.extras

Inputs
seqa sequence
quota quotation
nan integer


Outputs
?a boolean


Word description
Returns t if the sequence has exactly n elements where quot returns true, otherwise returns f.

Definition


: count= ( ... seq quot: ( ... elt -- ... ? ) n -- ... ? )
[ 0 ] 3dip [
[
[ [ swap ] ] dip [ dip swap [ 1 + ] when dup ] curry
compose
] dip [ > ] curry compose find 2drop
] keep = ; inline