Skip to content

Instantly share code, notes, and snippets.

@nvie
Created May 24, 2012 22:57
Show Gist options
  • Save nvie/2784760 to your computer and use it in GitHub Desktop.
Save nvie/2784760 to your computer and use it in GitHub Desktop.
Functional composition
def composition(f, *rest):
"""Creates the functional composition for the given functions."""
if len(rest) == 0:
return f
def _comp(*args, **kwargs):
g = composition(*rest)
return g(f(*args, **kwargs))
return _comp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment