Loading...
intermediate
Problem 08 • Step 01
A Function That Remembers
Define box in your language. box takes a value and returns a function that, when called, gives back that value.
evaluate(call(call("box", 7), 0)) // 7
evaluate(call(call("box", 42), 0)) // 42
The inner function takes a parameter because every function in the language must. But it ignores that parameter entirely. It already knows the answer, because x lives in its closure.
This is a function carrying a value. Not computing it, not transforming it. Just holding onto it and giving it back when asked.