Skip to content

Instantly share code, notes, and snippets.

@mirekfranc
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mirekfranc/bcbac0d62e8c5833b57a to your computer and use it in GitHub Desktop.
Save mirekfranc/bcbac0d62e8c5833b57a to your computer and use it in GitHub Desktop.
Reducing collection of predicates to a single predicate
def all_p (ps):
def __predicate (*args, **kwargs):
return all (p(*args, **kwargs) for p in ps)
return __predicate
def any_p (ps):
def __predicate (*args, **kwargs):
return any (p(*args, **kwargs) for p in ps)
return __predicate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment