Recursive Sum in Scala

Computing the total sum of a collection via a recursive Scala function.
def recursiveSum(xs: List[Int]): Int = 
    if (xs.isEmpty) 0
    else (xs.head + recursiveSum(xs.tail))

recursiveSum(List(1, 2, 3))

// res0: Int = 6
Scala
Over the last two articles of this series, we have discussed different Big Data file formats and their overall…
In today’s world, we’re constantly being bombarded with information from countless sources – news outlets, social media, blogs, etc….
Higher-order functions take other functions as arguments and/or return other functions as a result. These powerful abstractions allow us…
Functional programming is a powerful and elegant approach to tackling complex problems while creating maintainable code. Even though it…

Request Full Resume