Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 6149e8ff55
Fetching contributors…

Cannot retrieve contributors at this time

13 lines (11 sloc) 0.293 kB
import System.Environment
import Text.Printf
import Data.List (foldl')
main = do
[d] <- map read `fmap` getArgs
printf "%f\n" (mean [1..d])
mean :: [Double] -> Double
mean xs = s / fromIntegral n
where
(n, s) = foldl' k (0, 0) xs
k (n, s) x = n `seq` s `seq` (n+1, s+x)
Jump to Line
Something went wrong with that request. Please try again.