This section of the tour is for people who have never encountered the Scheme programming language before. We provide two small examples, and walk you through the basic operation of DrScheme. If you have seen Scheme, or plan to work through our textbook How to Design Programs (which relies heavily on DrScheme), you can skip this page.
Consider the following simple mathematical function
f2c (t) = 5/9 x (t - 32)
which converts degrees in fahrenheit to degrees in centigrade. It's easy to convert this function into a Scheme program: use define to introduce a new definition, and put the operators in front of their operands.
(define (f2c t) (* 5/9 (- t 32)))
You should type this function into the upper half of the DrScheme
window and click on the Run button. This loads the
function into the lower window, which is like an interactive
calculator. To test it, you could try three familiar values:
-40
, 32
and
212
. Whereas you would conventionally write
f2c(-40) f2c(32) f2c(212)
in Scheme you instead write
(f2c -40) (f2c 32) (f2c 212)
Try them out; see what answers you get!
Why does DrScheme produce these values? This is where the Stepper
becomes invaluable. It will display the step-by-step evaluation of the
expressions. To use it, put the evaluation expressions (such as
(f2c -40)
) in the upper window, then click the Step
button.
To learn more about Scheme, you should read the book, How to Design Programs. The rest of this tour will discuss specific features in the DrScheme environment.