Skip to content

Instantly share code, notes, and snippets.

@Aitozi
Created November 13, 2017 01:21
Show Gist options
  • Save Aitozi/c257ae328b7822dfe87024ee87b0db4b to your computer and use it in GitHub Desktop.
Save Aitozi/c257ae328b7822dfe87024ee87b0db4b to your computer and use it in GitHub Desktop.
scala惰性求值
def exists(p: A=> Boolean): Boolean = this match {
case Cons(h, t) => p(h()) || t().exists(p)
case _ => false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment