Workshop on Scheme

Exercises: Thursday, July 20

Reading: Scheme and the art of programming, chapter 11, sections 12.1 through 12.4, and chapter 13; Revised(4) report on the algorithmic language Scheme, sections 2, 7.1, and 7.3.


From Scheme and the art of programming: exercises 11.1, 11.5, 11.12, 12.1, 12.6, 12.10, and 13.5.


I'll use the term ``ampex'' for any Scheme procedure of arity 1 that takes any real number as argument and returns a real number as value. (Why ``ampex''? Because it represents a ``real-to-real'' function.)

Define a Scheme procedure ampex* that takes two ampexes (ampices?) as arguments and returns the product of the functions represent as an ampex. In other words, ((ampex* f g) x) should equal (* (f x) (g x)).


Define a Scheme procedure trapezoid that takes as arguments an ampex f, a real lower bound a, an real upper bound b, and an optional positive integer argument pieces and computes an approximation to the definite integral of the function expressed by f, from a to b, by the trapezoidal method, dividing the interval from a to b into the number of equal pieces specified by pieces (defaulting to 64).


Define a Scheme procedure list-set! that takes three arguments -- a list ls, an integer n with a value in the range from 0 (inclusive) to the length of ls (exclusive), and obj -- and mutates the argument ls so that its nth element is obj. (The value returned by the procedure is unspecified.)


This document is available on the World Wide Web as

http://www.math.grin.edu/~stone/events/scheme-workshop/Thursday-exercises.html


created July 19, 1995
last revised July 19, 1995

John David Stone (stone@math.grin.edu)