CS2322

Laboratory Problem 15

Unrestricted lambdas

In this problem we use the unrestricted lambda:

(lambda var expr1, expr2, ...)

which when applied to any number of arguments as:

(lambda var expr1, expr2, ...) operand1, operand2 , ...)

causes the expr1, expr2, ... to be evaluated in the environment of a binding of var to the list of arg1, arg2,... which are the values of operand1, operand2 ,.... Section 7.2 of the Springer and Friedman text gives several examples of the unrestricted lambda.

Use an unrestricted lambda to define new versions of the functions max and min so that they may be given an unlimited number of arguments as shown in the following examples:

(max 5 -10 15 -20) ==> 15

(max 5 -10 -20) ==> 5

(min 5 -10 15 -20) ==> -20

(min 5 -10 15) ==> -10

Lab 15 Scheme Code