CS170
Scheme Exercises
Here are a few simple function definitions to develop your acquaintance with
Scheme. Write and test the following Scheme functions.
- The function (copy s n) that makes n copies of the s-expression s.
E.g., (copy 'a 4) returns (a a a a).
- The function (nest s n) that makes n copies of the s-expression s,
but nested in parentheses.
E.g., (nest 'a 4) returns (a (a (a (a)))).
- The function (countdown n) that lists the numbers n down to 1.
E.g., (countdown 4) returns (4 3 2 1).
- The function (countup n) that lists the numbers 1 up to n.
E.g., (countup 4) returns (1 2 3 4).
Back to CS170 Home Page.