I have to define a highestAverage :: [[Int]] -> Double function that returns the highest average from a list of lists containing numbers.
For example:
bestAverage [[3,1], [5,4,3], [], [5,5,5], [1,2,3]] == 5.0
I have already written a function that returns the average of a list.
listAverage :: [Int] -> Double
listAverage [] = 0.0
listAverage x = fromIntegral(sum x)/fromIntegral(length x)
My problem is that I can't figure out a way to have it do recursion. I always get errors when loading in my module. My code right now looks like this:
highestAverage :: [[Int]] -> Double
highestAverage [[]] = 0.0
highestAverage (x:xs) = max(listAverage x, listAverage xs)