|
@@ -1505,18 +1505,20 @@ $\Rightarrow$
|
|
\end{tabular}
|
|
\end{tabular}
|
|
|
|
|
|
We recommend implementing \key{flatten} as a structurally recursive
|
|
We recommend implementing \key{flatten} as a structurally recursive
|
|
-function that returns two things, 1) the newly flattened expression,
|
|
|
|
-and 2) a list of assignment statements, one for each of the new
|
|
|
|
-variables introduced during the flattening the expression. The newly
|
|
|
|
-flattened expression should be an $\Arg$ in the $C_0$ syntax
|
|
|
|
-(Figure~\ref{fig:c0-syntax}), that is, it should be an integer or a
|
|
|
|
-variable. You can return multiple things from a function using the
|
|
|
|
-\key{values} form and you can receive multiple things from a function
|
|
|
|
-call using the \key{define-values} form. If you are not familiar with
|
|
|
|
-these constructs, the Racket documentation will be of help. Also, the
|
|
|
|
-\key{map2} function (Appendix~\ref{appendix:utilities}) is useful for
|
|
|
|
-applying a function to each element of a list, in the case where the
|
|
|
|
-function returns two values. The result of \key{map2} is two lists.
|
|
|
|
|
|
+function that returns three things, 1) the newly flattened expression,
|
|
|
|
+2) a list of assignment statements, one for each of the new variables
|
|
|
|
+introduced during the flattening the expression, and 3) a list of all
|
|
|
|
+the variables including both let-bound variables and the generated
|
|
|
|
+temporary variables. The newly flattened expression should be an
|
|
|
|
+$\Arg$ in the $C_0$ syntax (Figure~\ref{fig:c0-syntax}), that is, it
|
|
|
|
+should be an integer or a variable. You can return multiple things
|
|
|
|
+from a function using the \key{values} form and you can receive
|
|
|
|
+multiple things from a function call using the \key{define-values}
|
|
|
|
+form. If you are not familiar with these constructs, the Racket
|
|
|
|
+documentation will be of help. Also, the \key{map3} function
|
|
|
|
+(Appendix~\ref{appendix:utilities}) is useful for applying a function
|
|
|
|
+to each element of a list, in the case where the function returns
|
|
|
|
+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
|