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
Julia is a reasonably new, open-source, high-level, dynamically-typed programming language. It’s a multi-platform language supported on Linux, macOS, Windows and FreeBSD….
We live in an era where reliable data has become an invaluable asset. We’re constantly bombarded with information from…
Linux is well-established as an essential tool for developers, system administrators, cybersecurity analysts, and anyone working in the tech…
Programming paradigms play a crucial role in the realm of computer science. They act as blueprints or frameworks to…

Request Full Resume