
22 Sep
2016
22 Sep
'16
10:14 a.m.
It will work like this: meanList :: (Integral a, Fractional b) => [a] -> b meanList xs = fromIntegral (sumList xs) / (lengthList xs)
You probably meant -> b in the type signature, that was a typo.
And you need to insert fromIntegral to convert to Fractional before you can divide. Now that I see it I am beginning to wonder why it works, though, because I was just about to insert another fromIntegral before lengthList ... It works because in this case lengthList uses the fractional type b to
On 22/09/2016 16:08, Harald Bögeholz wrote: perfom its summation (it doesn't care about the type of the elements in xs). Cheers Sylvain