Lambda Calculus:
Given that cadr selects the second argument of a two parameter Curried function. Write a three parameter (Curried) Lambda Calculus function, ‘caddr’, that selects the third parameter/argument.
Expert Answer
// creates a pair of two values
pair := λx.λy.λf. fxy
// selects the first element of the pair
first := λp. p(λx.λy. x)
// selects the second element of the pair
second := λp. p(λx.λy. y)
// currys f
curry := λf.λx.λy . f (pair x y)
// uncurrys f
uncurry := λf.λp . f (first p) (second p)