Skip to content

Instantly share code, notes, and snippets.

Created February 16, 2016 22:14
What would you like to do?
Simple example of currying and creating higher-order functions
in Python.
Taken from
def curry2(f):
Returns a function g such that g(x)(y) == f(x, y)
>>> from operator import add
>>> add_three = curry2(add)(3)
>>> add_three(4)
def g(x):
def h(y):
return f(x, y)
return h
return g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment