Recursive Max in Scala

Determining the maximum value in a collection via a recursive Scala function.
def recursiveMax(xs: List[Int]): Int = 
    def compareMax(x: Int, y: Int): Int = 
        if (x > y) x
        else y
    if (xs.isEmpty) 0
    else compareMax(xs.head, recursiveMax(xs.tail))

recursiveMax(List(2, 6, 1, 6, 8, 10, 11, 0, 11, 20, 20))

// res0: Int = 20
Scala
Programming is an essential tool for innovation in the digital age, with businesses and organizations across all industries relying…
Markdown is a lightweight markup language used for creating formatted text. It was created in 2004 by John Gruber &…
Linux is well-established as an essential tool for developers, system administrators, cybersecurity analysts, and anyone working in the tech…
Data Analysis Expressions (DAX) is a domain-specific language created by Microsoft and used in various Microsoft products, particularly in…

Request Full Resume