The Scheme Programming Language: Chapter 2 (through Section 2.8).
Essentials of Programming Languages (EOPL): Chapter 1.
You may work singly or in pairs on this assignment.
Be sure to include contract and purpose statements for each
procedure you are asked to write.
(See the Homework Policy
for more details.)
To get you started, I have provided three files you should use.
Be sure to have this in the same directory as your hw02.ss. This file (from Friedman and Wand) defines the testing macro
(equal?? exp1 exp2)
Which prints an error message if the values of
exp1 and exp2 are
different and is silent if the values are equal.
While you are developing your scheme procedures, you may comment
out equal??-tests that you are not yet ready
for. Also, in your final homework submission, if there is
an equal??-test your code
does not pass, keep the test commented out and add an
explaination of what the trouble is. The file also
contains the definition of the procedure:
(report-unit-tests-completed proc-name)
which announces that tests for
proc-name have been passed.
An example of what a finished homework submission should look like. For the early homeworks, I want you to follow the format of this sample homework submission.
A start at each of the problems. I have provided contracts (but not purpose statements) and tests for each of the problems.
A copy of the source code and verified test cases demonstrating that your code is correct.
(12 points) EOPL, Exercise 1.16
(16 points) EOPL, Exercise 1.18
(16 points) EOPL, Exercise 1.21
(12 points) EOPL, Exercise 1.23 ⇐ CHANGED!!!
(12 points) EOPL, Exercise 1.24
(16 points) EOPL, Exercise 1.27
(16 points) Write a Scheme
procedure compose-all that takes an
arbitrary number of 1-argument procedures and returns their
composition. For example, compose-all should have
the following behavior:
> (define my-caddr (compose-all car cdr cdr)) > (my-caddr '(a b c d e)) c > (define plus1 (lambda (x) (+ x 1))) > (define times10 (lambda (y) (* y 10))) > ((compose-all times10 times10 plus1 plus1) 3) 500 > ((compose-all) 17) 17Note: The result of composing 0 procedures is the identity procedure (i.e., the procedure that returns the value of its argument).