Created
September 10, 2016 20:18
-
-
Save davcamer/5cd73fe0e79391ca11071f5e0a7cee05 to your computer and use it in GitHub Desktop.
Scala99 solutions
This file contains hidden or 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 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