takeWhile

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

takeWhile creates a collection by keeping the longest prefix of elements that satisfy a predicate p and discarding the rest.