I'm very new to Haskell, and I couldn't find the error in the following code:
arithmeticMean :: [Double] -> Double
arithmeticMean list = (sum list) / (length list)
I typed this into notepad, save it as "mean.hs", and tried to run it.
In GHCI, I typed :load mean and got the following error:
mean.hs:2:37:
Couldn't match expected type 'Double' with actual type 'Int'
In the second argument of '(/)', namely '(length list)'
In the expression: (sum list) / (length list)
Failed, modules loaded: none.
I apologize if I made a very trivial mistake, but I just don't see the problem. The function takes a list [Double], finds its sum, getting a double. Length takes any list and gives an int. I then divide a double by an int and return it. Why the error?