count method

int count(
  1. bool predicate(
    1. T
    )
)

Returns the number of elements satisfying predicate.

Implementation

int count(bool Function(T) predicate) =>
    fold(0, (acc, e) => predicate(e) ? acc + 1 : acc);