any() and all() on empty list?
Sybren Stuvel
sybrenUSE at YOURthirdtower.com.imagination
Wed Mar 29 02:24:23 EST 2006
Paul McGuire enlightened us with:
>> That goes against the usual meaning of "all" in, say, mathematical
>> logic.
>>
>> 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
mathematical operator.
> 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
> this.
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.
Sybren
--
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?
Frank Zappa
More information about the Python-list
mailing list