Re:Once you go functional, you can never go back
by tome on Thursday May 21, 2015 @02:25AM
(#9581231)
That's because the entries in fibs are thunks which become very large. This runs in constant space:
zipWith' f (x:xs) (y:ys) = let r = f x y in r `seq` r : zipWith' f xs ys
head (drop (10 ^ 9) (let fibs = 0 : 1 : zipWith max fibs (tail fibs) in fibs))
Do you expect the following code to run in constant space?
Neither ghci nor ghc seems to run it in constant space.