Re: [Haskell-cafe] How to implement the mean function

2011-07-01 Thread Ruohao Li
In the definition of `mean': mean xs = sum xs / length xs On Fri, Jul 1, 2011 at 2:00 PM, aditya siram aditya.si...@gmail.com wrote: What compiler errors are you getting? -deech On Fri, Jul 1, 2011 at 12:55 AM, Ruohao Li liruo...@gmail.com wrote: Hi guys, I just started learning some Haskell

Re: [Haskell-cafe] How to implement the mean function

2011-07-01 Thread Ruohao Li
/ fromIntegral (length xs) or try an integer division: mean xs = sum xs `div` length xs -n On Thu, Jun 30, 2011 at 10:55 PM, Ruohao Li liruo...@gmail.com wrote: Hi guys, I just started learning some Haskell. I want to implement a mean function to compute the mean of a list. The signature

Re: [Haskell-cafe] How to implement the mean function

2011-07-01 Thread Ruohao Li
://stackoverflow.com/questions/2376981/haskell-types-frustrating-a-simple-average-function On Jul 1, 2011, at 2:07 AM, Ruohao Li wrote: For mean xs = sum xs / length xs, I got the following: test.hs:8:10: No instance for (Fractional Int) arising from a use of `/' at test.hs:8:10-27

[Haskell-cafe] How to implement the mean function

2011-06-30 Thread Ruohao Li
Hi guys, I just started learning some Haskell. I want to implement a mean function to compute the mean of a list. The signature of the function is: mean :: (Num a, Fractional b) = [a] - b But when I implement this simple function, the compiler keep whining at me on type errors. I know this is