
On Fri, 2007-22-06 at 22:28 +0400, Bulat Ziganshin wrote:
no surprise - you got a lot of answers :) it is the best part of Haskell, after all :)
Yes, that is one of the best parts of Haskell. And I sometimes even understand the answers which is better!
the secret Haskell weapon is lazy evaluation which makes *everything* short-circuited. just consider standard (&&) definition:
(&&) False _ = False (&&) True x = x
Dammit! Teaches me to make assumptions. Of course "operators" in
Haskell are going to be JAF (Just Another Function). I didn't bother to
look one level lower than the foldr because I still have my C/C
++/practically-every-other-language-in-the-universe assumption that
"operators" are special syntactical constructs, not sugar for POBF
(Plain Old Boring Functions). Had I read the definitions of && and ||
I'd never have asked the question I did. I'd have got it right away.
(The irony is that even though the operators were being called as
functions in foldr, I have their use so ingrained in my head that I read
their use as functions in foldr and internally translated this to
imperative loops using operators!
I'd like to thank everybody for the various answers to this question.
It's been enlightening both on the front of remembering the subtleties
of Haskell's underlying assumptions and on the front of remembering what
a joy this community is.
--
Michael T. Richter