aspis.common.all

aspis.common.all(pred, iterable)

Returns True if all elements in the iterable satisfy the predicate.

Parameters:
  • pred (Callable) – The predicate function.

  • iterable (Iterable) – The iterable to be tested.

Returns:

True if all elements satisfy the predicate; otherwise, False.

Return type:

bool

Example

>>> all_satisfy(lambda x: x > 0, [1, 2, 3])
True
>>> all_satisfy(lambda x: x > 0, [1, -2, 3])
False