Skip to content

Instantly share code, notes, and snippets.

@sshh12
Created December 16, 2017 16:57
Show Gist options
  • Save sshh12/63cb074767d1f7032c3379652772b51e to your computer and use it in GitHub Desktop.
Save sshh12/63cb074767d1f7032c3379652772b51e to your computer and use it in GitHub Desktop.
def multiadder(n):
if n == 1:
return lambda t: t
else:
return lambda a: lambda b: multiadder(n-1)(a+b)
def multiadder2(n):
if n == 1:
def f(x):
return x
return f
else:
def f(a):
def g(b):
return multiadder2(n-1)(a+b)
return g
return f
print(multiadder(2)(1)(1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment