[Haskell-cafe] How to implement the mean function

aditya siram aditya.siram at gmail.com
Fri Jul 1 08:00:14 CEST 2011

What compiler errors are you getting?

On Fri, Jul 1, 2011 at 12:55 AM, Ruohao Li <liruohao at 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 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 wrong:
> mean xs = sum xs / length xs
> But how to get it right? Thanks.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list