query
On this page

count

lib.count

Docs pulled from | This Revision | 21 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
(lib.lists.count)

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;