Skip to content

Latest commit

 

History

History
13 lines (13 loc) · 471 Bytes

File metadata and controls

13 lines (13 loc) · 471 Bytes

Any and all

any returns True if any of the values in its input iterable are True.
all returns True if and only if all of the values in its input iterable are True.

print(any(True, False, True)) # -> True
print(all(True, False, True)) # -> False

These functions can be thought of as a reduction:

import functools as ft
any = lambda xs: ft.reduce(lambda p, q: p or q, xs, False)
all = lambda xs: ft.reduce(lambda p, q: p and q, xs, True)