[Haskell-beginners] Simple laplace solver

Francesco Bochicchio bieffe62 at gmail.com
Sat Mar 28 10:58:51 EDT 2009

2009/3/27 Edward Z. Yang <ezyang at mit.edu>

> Hello all,


> average :: Fractional a => [a] -> a
> average list = sum list / fromIntegral (length list)

There was a thread on this ML which was about an implementation of average
which avoids
traversing the list twice, one for 'sum' and one for 'length'. You could use
it, if you care for
performance and your list is long enough to matter

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20090328/b6153e56/attachment-0001.htm

More information about the Beginners mailing list