Adding to the answers above, if you use foldLeft, it's already tail call optimised
def Sphere(list: List[Double]): Double = {
list.foldLeft(0.0)((res, elem) => res + elem * elem)
}
It's better to use library versions and not add an extra check (@tailrec) for compiler when stuff's available.
**foldLeft is same as reduceLeft except that it takes an extra initial value as argument and not throw an exception when the collection is empty.
**foldLeft's actual implementation ends up using a while loop for performance reasons, but again that's the benefit of tail recursion, make it as fast as a loop.