Haskell script running out of space
问题 I'm using project Euler to teach myself Haskell, and I'm having some trouble reasoning about how my code is being executed by haskell. The second problem has me computing the sum of all even Fibonacci numbers up to 4 million. My script looks like this: fibs :: [Integer] fibs = 1 : 2 : [ a+b | (a,b) <- zip fibs (tail fibs)] evens :: Integer -> Integer -> Integer evens x sum | (even x) = x + sum | otherwise = sum main = do print (foldr evens 0 (take 4000000 fibs)) Hugs gives the error "Garbage