logoalt Hacker News

SilasX12/09/20241 replyview on HN

>The question becomes why all_of returns true for an empty list.

Yes! Before it became a programming problem, I considered the implications of this decision for common speech. In that case, it will generally be expected that when someone says "all my hats are green", they have at least one hat, probably because otherwise it doesn't hit the relevance threshold to make such a statement worth saying.[1]

Based on this, with my younger, hornier mind, I would joke that, "I have gone on a date with every female cheerleader at my university." (All the cheerleaders at my university are male.)

The idea being, an equally valid convention would be to read the statement as "there exists no element violating all the predicates" i.e. no one who is both a "female cheerleader at my university" and "someone I have not gone on a date with".

And this convention, it turns out, is what C's all_of (and Python's all()) uses.

But I'd still balk at someone using that trick in common speech -- it's at least an attempt to be misleading.

[1] See the "Maxim of Relevance": https://en.wikipedia.org/w/index.php?title=Cooperative_princ...


Replies

nuancebydefault12/09/2024

I make love to my wife almost every weekday. Almost monday, almost Tuesday, almost Wednesday,...