Tests foldLeft and foldRight of List in Scala.