Consider the following Python code:
a = 7
g = lambda x: a * x
a = 2
g(10)
- What is the result of evaluating the Python code?
20
- Convert the code to an expression in the Lambda Calculus
- Write an equivalent Python expression using the lambda keyword
g = lambda a: lambda x: lambda: a * x
g(10)(2)()
- What is the result of evaluating the Python expression?
In[0] : g(10)(2)()
Out[0]: 20
- What accounts for the difference between (1) and (4)?
Both results are 20.