any() and all() on empty list?
sybrenUSE at YOURthirdtower.com.imagination
Wed Mar 29 09:24:23 CEST 2006
Paul McGuire enlightened us with:
>> That goes against the usual meaning of "all" in, say, mathematical
>> Usually, "for all X in S, PRED(x) is true" means: there does not
>> exist X in S so that PRED(x) is false.
> How do you get this "usually" stuff?
>From its mathematical definition.
> I would agree that this is usually implemented as a short-circuited
> loop through the list, that breaks out at the first False value.
Implementation is irrelevant when it comes to the definition of a
> But I would not be quick to equate "commonality of implementation"
> with "meaning".
Which is good.
> Perhaps we should consult a more formal mathematical resource for
In mathematics, 'for all x in A, f(x) is True' is true when A is
empty. You can either look it up on trust someone who studied
mathematics (me) on it.
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
More information about the Python-list