Skip to content

Instantly share code, notes, and snippets.

@sourcepirate
Created January 11, 2017 15:58
Show Gist options
  • Save sourcepirate/3982c3efb49a11f26fb12c93bd08ca7a to your computer and use it in GitHub Desktop.
Save sourcepirate/3982c3efb49a11f26fb12c93bd08ca7a to your computer and use it in GitHub Desktop.
Currying
from functools import partial, wraps
def curry(f):
@wraps
def inner(*args, **kwargs):
return partial(f, *args, **kwargs)
return inner
@curry
def add_three(a, b, c):
return sum(a, b, c)
f = add_three(1)
print(f(2)(3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment