
28 Dec
2007
28 Dec
'07
10:50 a.m.
Right, so when I say to GHCi: Prelude> take 5 [1..] and it says: [1,2,3,4,5] then it really has computed the entirety of the infinite sequence [1..], and not some approximation?
Of course not! In fact, it doesn't even compute the value "1". It just juggles with the bytes somehow, so that it seems that it computes the whole sequence and then applies "take 5". But does it really matter if it computes 5 integers, or 10, or the whole sequence, at least if we are not concerned about performance?
Perhaps it is better to say that in a lazy language both approximations and maximal values (least upper bounds of a chain) are interesting.
Well, that depends of your notion of interesting.