This preview shows pages 1–3. Sign up to view the full content.
CS51 Assignment 5:
Midterm Review
Due: Tuesday, March 17th, 2009, 5:00PM
Total Points: 46
This assignment is a review of several of the concepts covered in class so far, and is meant
to mimic some of the questions you might see on the midterm. Although you can test many
of your functions by running them on your computer, be aware that Dr. Scheme won’t be
available on the midterm. Good luck studying!
1
Evaluation Rules
(10 points total)
Exercise 1.
7 points
(define f
)
For each of the following expressions, ﬁll in a deﬁnition of
f
such that the value of the
following expressions is 42, or state that this is impossible and explain why.
(a)
[1 point]
(f)
(b)
[2 points]
((f 1) 2 3)
(c)
[2 points]
(f 42 (f 42))
(d)
[2 points]
(+ (f (f 2)) (f 2))
Exercise 2.
3 points
(a)
[3 points]
Your good friend John Scheme is convinced that the builtin Scheme function,
or
, is too
slow. He decides to deﬁne his own
or
function. You inform your friend that this is not a
good idea, and that
myor
will behave diﬀerently than
or
. What is the problem? As part
of your explanation, you should include an example usage of
myor
that is not equivalent to
the same expression with
or
.
(
define
(
myor val1 val2
) (
if
val1
#
t val2
))
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document 3 HIGHER ORDER FUNCTIONS
CS51 Assignment 5: Midterm Review
2
Fun With Lists
(5 points total)
Exercise 3.
5 points
(a)
[2 points] Write
myreverse1
which reverses a list using the
This is the end of the preview. Sign up
to
access the rest of the document.
This note was uploaded on 07/26/2009 for the course COMPUTERSC CS51 taught by Professor Gregmorrisett during the Spring '09 term at Harvard.
 Spring '09
 GREGMORRISETT

Click to edit the document details