On Sunday 26 October 2003 09:39 am, Nick Coghlan wrote: > >>> if all(pred(x) for x in values): pass # alltrue > >>> if any(pred(x) for x in values): pass # anytrue Yeah, that does read nicely, which is why I think it's pretty common in FPLs. > >>> if any(not pred(x) for x in values): pass # anyfalse I've always expressed this as: if not all(pred(x) for x in values): pass > >>> if all(not pred(x) for x in values): pass # allfalse And this as: if not any(pred(x) for x in values): pass It's slightly more efficient (only one negation), and it seems to maintain better the pseudocode-like aspect that we so much adore in Python :) Jeremy
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