Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 13 lines (11 sloc) 0.293 kB
3056aea @astro much more content
astro authored
1 import System.Environment
2 import Text.Printf
3 import Data.List (foldl')
4
5 main = do
6 [d] <- map read `fmap` getArgs
7 printf "%f\n" (mean [1..d])
8
9 mean :: [Double] -> Double
10 mean xs = s / fromIntegral n
11 where
12 (n, s) = foldl' k (0, 0) xs
13 k (n, s) x = n `seq` s `seq` (n+1, s+x)
Something went wrong with that request. Please try again.