Answered! Given that cadr selects the second argument of a two parameter Curried function. Write a three parameter (Curried)…

Lambda Calculus:

(Note: cadr is a Lisp utility function that returns the second element in a list. In this case, realize that its returning the second argument in a two parameter Curried function. That is, its selecting the second argument. Dont worry about Currie functions. We mention it only because currying allows the representation of multiple argument functions since any multi-argument function can be rewritten as an equivalent function that accepts one argument.) 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

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)

Still stressed from student homework?
Get quality assistance from academic writers!