...
In order to use local and the other features about to be introduced in class, you need to set the DrScheme language level to Intermediate Student.
Exercises
Finding the maximum element of a list.
Let's consider the problem of finding the maximum number in a list which is used an example in Lecture 7.
...
In general, you can take any program using local
, and turn it into an equivalent program without local
.
Using local
doesn't let us write programs which were impossible before, but it does let us write them more cleanly and concisely.
Generating lists of ascending numbers
Retrieve your code for the up
function and its helper upfrom
from last lab.
...
These functions are very similar and can be written trivially using the Scheme library function map
discussed in Lecture 9.
Exercises.
- Write
double-nums and <3-nums
usingmap
.
...