package exer1
object excercise3 {
println("Welcome to the Scala worksheet")
def max(xs: List[Int]): Int = {
if (xs.isEmpty)
println("No Values in List")
else
compare(xs.head, xs.tail)
def compare(num: Int, tl: List[Int]): Int = {
if (tl.isEmpty)
num
else if (num > tl.head)
compare(num, tl.tail)
else
compare(tl.head, tl.tail)
}
}
}
I'm a new bee to Scala functional programming and during the course of learning, I wrote this program to get the max number among the list. But it is showing Type mismatch error. I'm not able to figure out what went wrong and where? Can anyone help me...!
}
beforedef compare()
... – ProGM