Created
December 16, 2017 16:57
-
-
Save sshh12/63cb074767d1f7032c3379652772b51e to your computer and use it in GitHub Desktop.
This file contains 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 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