>From the wiki: > If you write it, you force Haskell to create all list nodes. ...
Alright. Now, lets look at the definition again: > length [] = 0 > length (x:xs) = 1 + length xs We see that the value of *x* isnt needed at all. So, why does GHC allocate so much memory creating all those *x*s? because, if we have: length [1..] = 1 + length [2...] = 1 + 1 + length [3...] This should go on, into an infinite loop. GHC doesnt need to create all nodes! The wiki also claims that *x* isnt evaluated. So, why allocate space for it when its not evaluated? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe