Type declaration error

To Anthony Widjaja twidjaja@cometmail.com
18 Jul 2001 23:26:14 -0000

I've just tried writing a small code uses a function (/).
When hugs compiled it, it turned out that the type declaration is the error. For function every function (/) you had to use type class Fractional it says. But do we have to use Fractional every time we include (/)?
the code is as follows:
  more_less :: [(Int,Int)] -> ([(Int,Int)],[(Int,Int)])
  more_less x = ([ m | m <- x, map (snd x) >= mean x],    [ l | l <- x, map (snd x) < mean x]
                mean x = (sum (map snd x))/(length x)
What the code is intended to do is take a list of [(Int,Int)] and sort out the list in terms of their second value compared to the mean of the mean of the second values.
I look forward to hearing from everyone. Thanks


Sign up for your FREE E-MAIL @ COMETMAIL: