From Scheme and the art of programming: exercises 1.1, 1.3, 1.6, 1.14, 1.15, 2.2, 2.3, 2.5, 2.14, 2.24, 2.28, 3.2, 3.3, 3.7, 3.11, 3.16, 3.17, 4.2, 4.5, 4.7, 4.8, 4.14, 4.18, 4.20.
In exercise 2.2, the student is asked to write a procedure called
third
. The Scheme standard requires implementations to
provide this procedure as a built-in, though under a different name. Find
out what that name is by consulting the Revised(4) report on the
algorithmic language Scheme.
Exercise 2.21 and 3.5 in Scheme and the art of programming call for slightly lateral thinking, compared to the exercises that surround them. Investigate each one long enough to find out why.
Define a procedure that takes any complex number as its argument and returns its complex conjugate.
Define a procedure that takes as arguments the lengths of the two sides of a right triangle and returns the length of the hypotenuse. (Since this is too easy, I'll add a puzzle to it: For extra credit, use no more than two calls in the body of your definition, both to built-in procedures.)
In an implementation of Scheme that supports exact rationals, what value is
returned by the call (rationalize 314/100 1/100)
? (Note: SCM
does not support exact rationals and does not implement the
rationalize
procedure, so you'll have to find an alternative
approach to this one.)
For mathematicians: Define a rationalize
procedure, analogous
to the one described on page 22 of the Revised(4) report, for the
ratl
package developed in section 3.3 of Scheme and the art
of programming. It should accept any ratl
values for the
two arguments and return a ratl
value. (Theory hint:
continued fractions. Research hint: Hardy and Wright.)
This document is available on the World Wide Web as
http://www.math.grin.edu/~stone/events/scheme-workshop/Monday-exercises.html