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

Twan van Laarhoven twanvl at gmail.com
Fri Sep 21 06:15:45 EDT 2007


PR Stanley wrote:
> Hi
> or = foldl (||) False
> and = foldl (&&) True
> I can understand the rationale for the accumulator value - True && [] 
> where [] = True and True || [] where [] = False
> Other than the practical convenience is there a reason for having the 
> empty list in and and or equating to True and False?
> Thanks, Paul

Another way to think about this is to look at

 > any p = or . map p
 > all p = and . map p

Now, "all even []" should hold, since everything in that list is even. 
But not "any even []" because there is no even number in the empty list.

Twan


More information about the Haskell-Cafe mailing list