a pairs may be represented using a lambda using


(a) Pairs may be represented using a lambda. Using only lambdas, create a procedure (triple x y z) that constructs a triplet. You may NOT use car, cons or cdr in the triplet procedures. Using this formulation for a triplet, write procedures first, second and third that return the first, second and third elements of the triplet respectively.
For example:

(define a (triple 1 2 3))
(first a) => 1
(second a) => 2
(third a) => 3

(b) Using the substitution model, show how (first a) returns the value 1.

(c) Develop another alternative representation of triples. Write the corresponding constructor, first, second and third procedures, along with set-first!, set-second! and set-third!. You may not use car, cdr or cons in this second implementation.

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: a pairs may be represented using a lambda using
Reference No:- TGS0219130

Expected delivery within 24 Hours