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- 30 min
- Blog
- Computer Science
- PowerShell 7, Python, Scala, VS Code
Scala is a strong, statically typed, high-level, general-purpose programming language that supports both object-oriented programming and functional programming. It…