Consider the following JavaScript expression:

function (x) {
    return function (y) {
               return function (x) {
                          return function (z) {
                                     return x(y)(z);
                          };
               };
    };
}

Which one of the following expressions is a λ expression that is equivalent to the code given above?

λa.λb.λa.λc.((a b) c)
  • λa.λb.λa.λc.(a b c)
  • λy.λz.λy.λx.((y x) z)
  • λx.λy.λx.λz.(x (y z))
  • None of the other options is correct.

Recall that all functions in the lambda calculus are curried.

Scoping rules are the same in JavaScript and the lambda calculus.

Pay special attention to the use of parentheses in function calls in JavaScript and in function applications in the lambda calculus.