count

trait Collection[A] {
  def count(p: (A) => Boolean): Int
}

count determines how many elements in this collection satisfy the predicate p.