Created
January 11, 2017 15:58
-
-
Save sourcepirate/3982c3efb49a11f26fb12c93bd08ca7a to your computer and use it in GitHub Desktop.
Currying
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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