Skip to content

Instantly share code, notes, and snippets.

@ceeblet
Created March 10, 2015 20: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 ceeblet/b8d99f6614409ab4792e to your computer and use it in GitHub Desktop.
Save ceeblet/b8d99f6614409ab4792e to your computer and use it in GitHub Desktop.
console session demonstrating function composition
>>> def compose(g, h):
... def anon(x):
... return g(h(x))
... return anon
...
>>> f3 = compose(f1, f2)
>>> f3("Shillalegh")
<__main__.Func object at 0x100569dd0>('Shillalegh') called
f1('Shillalegh') called
'Shillalegh'
@ceeblet
Copy link
Author

ceeblet commented Mar 10, 2015

f1 and f2 were previously defined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment