def myfunc(n):
def multiplier(a):
return a * n
return multiplier
mydoubler = myfunc(2)
print(mydoubler(11)) # 22
myfunc = lambda n: lambda a: a * n
mydoubler = myfunc(2)
print(mydoubler(11)) # 22
Both sides represent the mathematical term: λn.λa.an
lambda n and lambda a are the variable binders. They create the "slots" for your numbers.mydoubler(11), you are performing Application. You are plugging 11 into the 'a' slot.n was 2. This is called lexical scoping.