query
On this page

count

lib.lists.count

Docs pulled from | This Revision | 11 minutes ago


Count how many elements of list match the supplied predicate function.

Inputs

pred

Predicate

Type

count :: (a -> bool) -> [a] -> int

Examples

lib.lists.count usage example

count (x: x == 3) [ 3 2 3 4 6 ]
=> 2

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

count =
    pred: foldl' (c: x: if pred x then c + 1 else c) 0;