> it might be "alltrue" and "anytrue" -- the short-circuiting ones, > returning the first true or false item found respectively, as in: > > def alltrue(seq): > for x in seq: > if not x: return x > else: > return True > > def anytrue(seq): > for x in seq: > if x: return x > else: > return False > > these seem MUCH more generally useful than 'product' (but, > I still opine, not quite enough to warrant being built-ins). These are close to what ABC does with quantifiers. There, you can write IF EACH x IN sequence HAS x > 0: ... ABC has the additional quirk that if there's an ELSE branch, you can use x in it (as a "counter-example"). In Python, you could write this as if alltrue(x > 0 for x in sequence): ... but the current design doesn't expose x to the else branch. --Guido van Rossum (home page: http://www.python.org/~guido/)
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