|
@@ -1290,7 +1290,7 @@ include at least one \key{return} statement. Each program is also
|
|
annotated with a list of variables (viz. {\tt (var*)}). At the start
|
|
annotated with a list of variables (viz. {\tt (var*)}). At the start
|
|
of the program, these variables are uninitialized (they contain garbage)
|
|
of the program, these variables are uninitialized (they contain garbage)
|
|
and each variable becomes initialized on its first assignment. All of
|
|
and each variable becomes initialized on its first assignment. All of
|
|
-the variables used in the program must be present in this list.
|
|
|
|
|
|
+the variables used in the program must be present in this list exactly once.
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
\fbox{
|
|
\fbox{
|
|
@@ -1554,20 +1554,26 @@ should be an integer or a variable. You can return multiple things
|
|
from a function using the \key{values} form and you can receive
|
|
from a function using the \key{values} form and you can receive
|
|
multiple things from a function call using the \key{define-values}
|
|
multiple things from a function call using the \key{define-values}
|
|
form. If you are not familiar with these constructs, the Racket
|
|
form. If you are not familiar with these constructs, the Racket
|
|
-documentation will be of help. Also, the \key{map3} function
|
|
|
|
|
|
+documentation will be of help.
|
|
|
|
+Also, the \key{map3} function
|
|
(Appendix~\ref{appendix:utilities}) is useful for applying a function
|
|
(Appendix~\ref{appendix:utilities}) is useful for applying a function
|
|
to each element of a list, in the case where the function returns
|
|
to each element of a list, in the case where the function returns
|
|
three values. The result of \key{map3} is three lists.
|
|
three values. The result of \key{map3} is three lists.
|
|
|
|
|
|
The clause of \key{flatten} for the \key{program} node needs to
|
|
The clause of \key{flatten} for the \key{program} node needs to
|
|
recursively flatten the body of the program and the newly flattened
|
|
recursively flatten the body of the program and the newly flattened
|
|
-expression should be placed in a \key{return} statement. The
|
|
|
|
-\key{flatten} pass should also compute the list of variables used in
|
|
|
|
-the program. I recommend traversing the statements in the body of the
|
|
|
|
-program (after it has been flattened) and collect all variables that
|
|
|
|
-appear on the left-hand-side of an assignment. Note that each variable
|
|
|
|
-should only occur once in the list of variables that you place in the
|
|
|
|
-\key{program} form.
|
|
|
|
|
|
+expression should be placed in a \key{return} statement. Remember that
|
|
|
|
+the variable list in the \key{program} node should contain no duplicates.
|
|
|
|
+%% The
|
|
|
|
+%% \key{flatten} pass should also compute the list of variables used in
|
|
|
|
+%% the program.
|
|
|
|
+%% I recommend traversing the statements in the body of the
|
|
|
|
+%% program (after it has been flattened) and collect all variables that
|
|
|
|
+%% appear on the left-hand-side of an assignment.
|
|
|
|
+%% Note that each variable
|
|
|
|
+%% should only occur once in the list of variables that you place in the
|
|
|
|
+%% \key{program} form.
|
|
|
|
+
|
|
|
|
|
|
Take special care for programs such as the following that initialize
|
|
Take special care for programs such as the following that initialize
|
|
variables with integers or other variables. It should be translated
|
|
variables with integers or other variables. It should be translated
|