3 ms·
“Are there any items in this list that are true? No? Ok, then False” I don’t care about any fancy philosophy. What’s important is what kind of operation you wa
by dkersten 3y ago
“Are there any items in this list that are true? No? Ok, then False”
I don’t care about any fancy philosophy. What’s important is what kind of operation you want for when implementing algorithms, and False is what I always want in cases where I do “all”.
- kadoban 3y ago> “Are there any items in this list that are true? No? Ok, then False” There's no particular reasoning that this is any more compelling than: “Are there any items in this list that are false? No? Ok, then True”
- jamilton 3y ago"is any item in this list true" is any(), which is different from all().
- CJefferson 3y agoCan you give a couple of examples where you want False for an empty all? I'd be interested to see them, as I've found I always want True.
- robot_no_421 3y ago> What’s important is what kind of operation you want for when implementing algorithms, and False is what I always want in cases where I do “all”. Why would you want "all" to produce results that are inconsistent with logic and mathematics? Consider this tautology, which is a result of De Morgan's laws: for any list L, we have that all(L) == ~any([~x for x in L]). In other words, if all([]) == False, then you would also logically need to accept that: False == all([]) == ~any([~x for x in []]) == ~any([]) which means that we'd require any([]) == True. And that's definitely an illogical result.
- stop50 3y agoYou can define all() as "is there any False item?" Which is False for an empty list, but true for any list with an false item. all(list) == anyfalse(list)
- shawnz 3y agoYou're describing the "any" function, which actually does return false in that case already.