Skip to content

Instantly share code, notes, and snippets.

@tpolecat
Created September 21, 2013 05:01
Show Gist options
  • Save tpolecat/6647383 to your computer and use it in GitHub Desktop.
Save tpolecat/6647383 to your computer and use it in GitHub Desktop.
def exists[A](as: List[A], f: A => Boolean): Boolean =
as match {
case Nil => false
case a :: as0 => if (f(a)) true else exists(as0, f)
}
def forall[A](as: List[A], f: A => Boolean): Boolean =
!exists(as, (a: A) => !f(a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment