
24 Sep
2007
24 Sep
'07
4:26 p.m.
Vimal wrote:
Hi all,
I was surprised to find out that the following piece of code:
length [1..] > 10
isnt lazily evaluated! I wouldnt expect this to be a bug, but in this case, shouldnt the computation end when the length function evaluation goes something like:
10 + length [11..]
10", *we* are smart enough to break apart the left-hand argument to (>) and inspect the arguments to (+), observe that "length" will never return a negative value, and concluded that we can stop evaluating. But
I suspect that > when defined on integers is strict in both arguments, i.e., defined to not be lazily evaluated. Even if it's not, when the reduction gets as far as "11 + length [12..] the implementation of (>) is not so smart.