What happens if you change the signature of meanList to
meanList :: ( Fractional b) => [b] ->b
The integrals in [1,2,3] would be converted to [1.0, 2.0, 3.0] before you act upon them.
Hi, can someone explain to me why i cannot define meanList as:meanList :: (Integral a, Fractional b) => [a] -> ameanList xs = (sumList xs) / (lengthList xs)I want to restrict the function to only accept lists like [1,2,3] and return answer 2.0sumList :: (Num a) => [a] -> asumList [] = 0sumList (x:xs) = x + (sumList xs)lengthList :: (Num a) => [t] -> alengthList [] = 0lengthList (_:xs) = 1 + (lengthList xs)
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners