-- strict foldl: O(n) space required foldl' :: (a -> b -> a) -> a -> [b] -> a foldl' f a [] = a foldl' f a (x:xs) = (foldl' f $! f a x) xs suml' :: (Num a) => [a] -> (a,Int) suml' = foldl' (\(s,l) x -> (s+x,l+1)) (0,0) mean' xs = (fst p) / fromIntegral (snd p) where p = suml' xs suml :: (Num a) => [a] -> (a,Int) suml = foldl (\(s,l) x -> (s+x,l+1)) (0,0) mean xs = (fst p) / fromIntegral (snd p) where p = suml xs