[an error occurred while processing this directive] [an error occurred while processing this directive]
![]() |
|
Scheme is a programming language designed to solve problems that can be inherently expressed in terms of functions. Functional programming (FP) is formulating problems in terms of functions and writing programs as functions to solve the formulated problems. Scheme is said to be a FP language because Scheme programs are expressed as collections of one or more functions.
In this chapter, we will work on a series of problem solving in Scheme to gain some insight on what FP is. We will do many of them in class on the computer. We will use the book How to Design Programs extensively and DrScheme as the programming environment to program in Scheme. When you run DrScheme, be sure to set the language level to Beginning Student using the Language menu: Language/Choose Language...
A Scheme expression can be either atomic or compound.
An atomic expression is, for now, something like a number or a variable name.
A variable name is a sequence of character symbols with at least one non-numeric character. For examples, 1a, a1, a1b2cdf are variable names.
123 is sequence of numeric characters representing a number and is not a variable name.
A compound expression is something that stats with a left parenthesis "(", followed by an operation name, followed by a sequence of zero or more Scheme expressions, and terminated by a right parenthesis ")". For examples, (* 2 (+ 3 4)), (sqrt 100) are compound expressions.
An operation name can be a reserved symbol (e.g. +, -, * \), a predefined function name (e.g. sqrt, sin), or a user-defined function (e.g. Celsius2Fahrenheit).
Scheme expressions are said to be in prefix notation.
Write a function to compute the area of a rectangle. (What input parameter(s) should it have?)
Write a function to compute the area of a circle. (What input parameter(s) should it have?)
Write a function to compute the area of a ring. (What input parameter(s) should it have?)
© Dung X. Nguyen
Last revised 08/24/2008 09:03 PM