[Haskell-cafe] Accumulator value for "and" and "or"

Matthew Brecknell haskell at brecknell.org
Thu Sep 20 23:03:43 EDT 2007

PR Stanley:
> or = foldl (||) False
> and = foldl (&&) True
> [...]
> Other than the practical convenience is there a reason for having the 
> empty list in and and or equating to True and False?

It might help to think of "and" as a kind of product, and "or" as a kind
of sum, and note that:

sum [] = 0
product [] = 1

If it seems odd that the product of an empty list should be 1, then
consider why x^0 = 1 for any x /= 0, and so on.

More information about the Haskell-Cafe mailing list