Jeremy Fincher strung bits together to say: > On Saturday 25 October 2003 11:36 pm, Guido van Rossum wrote: > >>Do we need allfalse() and anytrue() and anyfalse() too? These can all >>easily be gotten by judicious use of 'not'. I think ABC has EACH, >>SOME and NO (why not all four? who knows). > > There was a recent thread here ("Efficient predicates for the standard > library") in which the names "any" and "all" were discussed rather than > "anytrue" and "alltrue." Those are at least their common names in the > functional programming languages I know, and it easily sidesteps the > confusion that might be caused by having an "anytrue" without an "anyfalse" > or an "alltrue" without an "allfalse." >>> if all(pred(x) for x in values): pass # alltrue >>> if any(pred(x) for x in values): pass # anytrue >>> if any(not pred(x) for x in values): pass # anyfalse >>> if all(not pred(x) for x in values): pass # allfalse The names from the earlier thread do read nicely. . . Alternately, getting away with just one function: >>> if all(pred(x) for x in values): pass # alltrue >>> if not all(not pred(x) for x in values): pass # anytrue >>> if not all(pred(x) for x in values): pass # anyfalse >>> if all(not pred(x) for x in values): pass # allfalse I don't know about anyone else, but the double negative required to express "any" in terms of "all" hurts my brain. . . Cheers, Nick. -- Nick Coghlan | Brisbane, Australia ICQ#: 68854767 | ncoghlan at email.com Mobile: 0409 573 268 | http://www.talkinboutstuff.net "Let go your prejudices, lest they limit your thoughts and actions."
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4