Skip to content

Instantly share code, notes, and snippets.

@nite
Last active May 29, 2017 21:36
Show Gist options
  • Save nite/c030c45f87cce0b69e1ab6d4ccbda4a5 to your computer and use it in GitHub Desktop.
Save nite/c030c45f87cce0b69e1ab6d4ccbda4a5 to your computer and use it in GitHub Desktop.
A simple curry function in python
def curry(func):
def f(*args):
outerArgs = args
next = lambda *args : f(*args, *outerArgs)
next.value = lambda: func(args)
return next
return f
add = curry(sum)
print(add(1,2,3)(5,6).value()) # 17
print(add(1)(2)(7,8).value()) # 18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment