Created
September 21, 2013 05:01
-
-
Save tpolecat/6647383 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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