object Scala99Problem01{
def lastElement[A](ls: List[A]):A = {
def lastElementAux[A](ls: List[A]): Option[A] = ls match{
case Nil => None
case x :: Nil => Some(x)
case x :: xs =>
Yay! Just finished Functional Programming Principles in Scala (with 100% score :D) instructed by Prof. Martin Odersky et al, at Coursera. It has been an excellent experience due to its great content, amazing
Ira Glass's advice for beginners:
In the following video, Ira Glass explains the above presentation:
There are several ways to accomplish this. Next code snippet shows how to compute min and max using reduceLeft.
val ls = List(1,2,3,4,5)
ls.reduceLeft(_ min _) // is equivalent to
This post discusses a O(n) algorithm that construct a balanced binary search tree (BST) from a sorted list. For instance, consider that we are given a sorted list: [1,2,3,4,