Laziness and tail recursion in Haskell, why is this crashing?
问题 I have this fairly simple function to compute the mean of elements of a big list, using two accumulators to hold the sum so far and the count so far: mean = go 0 0 where go s l [] = s / fromIntegral l go s l (x:xs) = go (s+x) (l+1) xs main = do putStrLn (show (mean [0..10000000])) Now, in a strict language, this would be tail-recursive, and there would be no problem. However, as Haskell is lazy, my googling has led me to understand that (s+x) and (l+1) will be passed down the recursion as