Created
June 7, 2015 15:51
-
-
Save nsfyn55/8749b340e6136f192069 to your computer and use it in GitHub Desktop.
Currying Example
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
def add(x, y): | |
return x + y | |
def add_curried(x): | |
def partial(y): | |
return x + y | |
return partial | |
print add(3,4) | |
# full application | |
print add_curried(3)(4) | |
# partial application | |
add_one = add_curried(1) | |
print add_one(2) | |
print add_one(3) | |
print add_one(4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment