...
Note that you can write an efficient solution without using local
; you can use an auxiliary function instead. The auxiliary function takes the expression appearing on the right hand side of the local definition as an argument. Quickly write this version of ma the function including a contra.
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.
...
Now that we have extended our hand-evaluation model to include the definitions forming a program, we can describe how to handle define
statements that bind ordinary variables rather than functions. The right hand sides of define}
statements are not necessarily values. When evaluating a program, you must always reduce the leftmost expression that is not a value; in some cases this expression may be part of the right hand size of a {{define
.
Sample evaluations involving local
and explicit program text
...
Note the preceding definitions of filter
are not acceptable to DrScheme because the name filter
collides with the Scheme library function named filter
(which performs the same operation). If you want to run either of the preceding programms programs in DrScheme, you will have to rename filter
(as say Filter
).
...
Do not bother writing a contract, purpose statement, ortemplate or template instantiation for this function since we recommend that you throw this code away after the lab is over. The name has been changed to Filter} to avoid colliding with the Scheme library function named {{filter
.
...