Week 13 Set a
Due Date Mon at 9:00pm (Week 13)
Purpose to get a first impression of syntax transformations
Finger Exercises
Exercise 1 Design the function if-transformer, which transforms the S-expression representation of an if expression into a cond expression.
Exercise 2 Design the function local-transformer, which transforms the S-expression representation of an additive local expressions into the S-expression representations of an immediate application of a lambda expression.
(local ((define name1 (+ Expression1-1 Expression1-2)) ... (define nameN (+ ExpressionN-1 ExpressionN-2))) Expression) As usual the expressions in line i + 1 may refer to the names defined in lines 1 through i (and of course any names defined outside of the local expression).An immediate application of a lambda expression refers to the idea that the latter can appear in function position. For example,((lambda (x) x) 10)
Hint Experiment with check-expect on real local and lambda expressions first to make sure you understand how these two kinds of expressions are equivalent.
Graded Exercises
Exercise 3 Design the function cond-transformer, which transforms an S-expression representation of a cond expression into an S-expression representation of nested if expressions.
Exercise 4 Design the function curry, which transforms the S-expression representation of a multi-argument lambda expression of many arguments into a nest of one-argument (representations of) lambda expressions.
History The name of the function honors Haskell Curry, the logician who realized that working with n nested one-argument lambda expressions with distinct parameters is equivalent to an n-argument lambda (with the same n parameters).