Goals: This lab provides practice with simple user-defined
Write a Scheme procedure (add2 a) that returns the sum a+2.
Define a procedure f(x) = x² - 3x + 2 and evaluate it for
x = 0, 1, 2, 3, 4 .
Write a procedure (quadratic-root a b c) that finds one root of a
ax² + bx + c = 0 using the quadratic
formula. Use it to find a root of the above equation.
Test your procedure by computing
(quadratic-root 1 -5 6)
(quadratic-root 2 -10 12)
(quadratic-root 1 4 4).
each case, use algebra to check your answers.
What are (quadratic-root 1 0 1) and (quadratic-root 1 0
[Would these two examples work in other programming languages
that you know?]
Write a procedure swap that interchanges the first two elements on a
list, leaving the rest of the list unchanged. Thus, (swap '(a b c d
e)) should return (b a c d e). In this problem, assume that the
list given to swap has at least two elements; do not worry about the
possibility that swap might be applied to numbers, empty lists, or
lists with only one element.
Textbook Exercises: As you have time, work on exercises 2.1-2.5 from
This document is available on the World Wide Web as
created January 22, 1997
last revised February 2, 1997