Skip to content

Instantly share code, notes, and snippets.

@davcamer
Created September 10, 2016 20:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davcamer/5cd73fe0e79391ca11071f5e0a7cee05 to your computer and use it in GitHub Desktop.
Save davcamer/5cd73fe0e79391ca11071f5e0a7cee05 to your computer and use it in GitHub Desktop.
Scala99 solutions
def last[A](l: List[A]) = l match {
case head :: tail => tail.foldLeft(head)((a,e) => e)
case _ => throw new NoSuchElementException
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment