Hello.
- All the answers are at the end of this mail.
----------------------------------------------------- 1) Are e1 and e2 equal?
f (x:xs) y = x g (x:xs) = \y -> x
e1 = seq (f []) 1 e2 = seq (g []) 1
Should not these be f (x:xs) y = y g (x:xs) = \y -> y ? Otherwise, both e1 and e2 are obviously undefined. Zdenek Dvorak _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com
Zdenek Dvorak wrote:
----------------------------------------------------- 1) Are e1 and e2 equal?
f (x:xs) y = x g (x:xs) = \y -> x
e1 = seq (f []) 1 e2 = seq (g []) 1
Should not these be
f (x:xs) y = y g (x:xs) = \y -> y ? Otherwise, both e1 and e2 are obviously undefined. That seems to be obvious, but e1 is NOT undefined! That's the point Daan makes.
seq forces it's first argument and returns the second one. However, because f is partially parametrized, seq doesn't change anything in f and just returns 1. The right-hand-side of f is not involved at all! In e2 though, g is fully parametrized, so seq behaves as you expect and the pattern match failes. Rijk-Jan
participants (2)
-
Rijk J. C. van Haaften -
Zdenek Dvorak