Skip to content

prep for scheme json version #1078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 4 additions & 18 deletions xml/chapter2/section3/subsection4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,7 @@ BACADAEAFABBAAAGAH</TD></TR></TABLE>
there is only one node left, which is the root of the entire tree.
Here is how the Huffman tree of figure<SPACE/><REF NAME="fig:huffman"/> was
generated:
<SPLIT>
<SCHEME>
<FIGURE src="img_tex/ch2_3_4-3.png"></FIGURE>
</SCHEME>
<JAVASCRIPT>
<TABLE>
<TABLE>
<TR SINGLESPACE="yes">
<TD>
Initial leaves
Expand Down Expand Up @@ -305,9 +300,7 @@ BACADAEAFABBAAAGAH</TD></TR></TABLE>
<LATEXINLINE>$\{$</LATEXINLINE>(<LATEXINLINE>$\{$</LATEXINLINE>A B C D E F G H<LATEXINLINE>$\}$</LATEXINLINE> 17)<LATEXINLINE>$\}$</LATEXINLINE>
</TD>
</TR>
</TABLE>
</JAVASCRIPT>
</SPLIT>
</TABLE>
The algorithm does not always specify a unique tree, because there may
not be unique smallest-weight nodes at each step. Also, the choice of
the order in which the two nodes are merged (i.e., which will be the
Expand Down Expand Up @@ -1052,12 +1045,7 @@ equal(sample_tree,
<INDEX>rock songs, 1950s</INDEX>
rock songs. (Note that the <QUOTE>symbols</QUOTE> of an
<QUOTE>alphabet</QUOTE> need not be individual letters.)
<SPLIT>
<SCHEME>
<FIGURE src="img_tex/ch2_3_4-4.png"></FIGURE>
</SCHEME>
<JAVASCRIPT>
<TABLE>
<TABLE>
<TR SINGLESPACE="yes">
<TD>
A
Expand Down Expand Up @@ -1128,9 +1116,7 @@ equal(sample_tree,
<SPACE/><SPACE/>1
</TD>
</TR>
</TABLE>
</JAVASCRIPT>
</SPLIT>
</TABLE>
Use
<SPLITINLINE>
<SCHEME><SCHEMEINLINE>generate-huffman-tree</SCHEMEINLINE></SCHEME>
Expand Down
1 change: 1 addition & 0 deletions xml/chapter3/section1/subsection3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,7 @@ paul_acc("withdraw", "rosebud")(50); // Withdraws 50, should return 40
</EXERCISE>

<EXERCISE>
<LABEL NAME="ex:3_8"/>
When we defined the evaluation model in
section<SPACE/><REF NAME="sec:evaluating-combinations"/>, we said that the
<INDEX>order of evaluation<SUBINDEX><ORDER>JavaScript</ORDER>in JavaScript</SUBINDEX></INDEX>
Expand Down
3 changes: 3 additions & 0 deletions xml/chapter3/section2/section2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,7 @@
<!-- Subsection 4 : Internal Definitions -->
&amp;subsection3.2.4;

<!-- Subsection 5 : CSE Machine -->
&amp;subsection3.2.5;

</SECTION>
52 changes: 52 additions & 0 deletions xml/chapter3/section2/subsection5.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<SUBSECTION>
<NAME>
CSE Machine
</NAME>

<LABEL NAME="sec:cse-machine"/>
<INDEX>CSE machine<OPEN/></INDEX>

<SPLIT>
<JAVASCRIPT>
<TEXT>
The environment model as presented so far focuses on how functions can refer
to their parameters, locally declared names, and names that are declared
outside the function. We achieve this by evaluating statements and expressions
with respect to a <EM>current environment</EM>. It does not specify how
we keep track of environments as computation proceeds. For example, when we
evaluate an expression <JAVASCRIPTINLINE>f(x) + y</JAVASCRIPTINLINE>, we
need to evaluate <JAVASCRIPTINLINE>x</JAVASCRIPTINLINE> in the current
environment, establish as the new current environment the environment of
<JAVASCRIPTINLINE>f</JAVASCRIPTINLINE> extended by a binding of its
parameter to the value of <JAVASCRIPTINLINE>x</JAVASCRIPTINLINE>, and
evaluate the body of <JAVASCRIPTINLINE>f</JAVASCRIPTINLINE> in this
extended environment. But what environment should we use for evaluating
<JAVASCRIPTINLINE>y</JAVASCRIPTINLINE> after
<JAVASCRIPTINLINE>f</JAVASCRIPTINLINE> returns?
In this section, we extend the
</TEXT>

<SUBHEADING><NAME>Evaluating arithmetic expressions</NAME></SUBHEADING>

<TEXT>
Exercise<SPACE/><REF NAME="ex:3_8"/> shows that the presence of
assignments makes the result of a program depend on the order in which
the operands of an operator combination are evaluated. To remove
ambiguities that arise from this, the JavaScript standard specifies
left-to-right evaluation of operands.

As an example, consider the evaluation of the arithmetic expression statement
<SNIPPET>
<JAVASCRIPT>
1 + (2 * 3);
</JAVASCRIPT>
</SNIPPET>
The expression is decomposed into its operands
<JAVASCRIPTINLINE>1</JAVASCRIPTINLINE> and
<JAVASCRIPTINLINE>2 * 3</JAVASCRIPTINLINE>, followed by the
<EM>instruction</EM> to add their results.
</TEXT>
<INDEX>CSE machine<CLOSE/></INDEX>
</JAVASCRIPT>
</SPLIT>
</SUBSECTION>
10 changes: 9 additions & 1 deletion xml/chapter3/section5/subsection2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,15 @@ const fibs = pair(0,
by adding <SCHEMEINLINE>fibs</SCHEMEINLINE> to itself shifted by one place:
<SPLIT>
<SCHEME>
<FIGURE src="img_tex/ch3_5_2-1.png"></FIGURE>
<LATEX>
\[
\begin{array}{ccccccccccccl}
&amp; &amp; 1 &amp; 1 &amp; 2 &amp; 3 &amp; 5 &amp; 8 &amp; 13 &amp; 21 &amp; \ldots &amp; = &amp; \texttt{(stream-cdr fibs)} \\
&amp; &amp; 0 &amp; 1 &amp; 1 &amp; 2 &amp; 3 &amp; 5 &amp; 8 &amp; 13 &amp; \ldots &amp; = &amp; \texttt{fibs} \\ \hline
0 &amp; 1 &amp; 1 &amp; 2 &amp; 3 &amp; 5 &amp; 8 &amp; 13 &amp; 21 &amp; 34 &amp; \ldots &amp; = &amp; \texttt{fibs}
\end{array}
\]
</LATEX>
</SCHEME>
<JAVASCRIPT>
<LATEX>
Expand Down
13 changes: 11 additions & 2 deletions xml/chapter5/section5/subsection1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,16 @@ go_to(reg("continue"))
<!-- %Whew! What a pain it was to set this, because of the blank lines. -->
<SPLIT>
<SCHEME>
<FIGURE src="img_original/preserving_table.svg"></FIGURE>
\[
\begin{array}{l|l|l|l}
\textit{seq}_1 &amp; \texttt{(save}\ \textit{reg}_1\texttt{)} &amp; \texttt{(save}\ \textit{reg}_2\texttt{)} &amp; \texttt{(save}\ \textit{reg}_2\texttt{)} \\
\textit{seq}_2 &amp; \textit{seq}_1 &amp; \textit{seq}_1 &amp; \texttt{(save}\ \textit{reg}_1\texttt{)} \\
&amp; \texttt{(restore}\ \textit{reg}_1\texttt{)} &amp; \texttt{(restore}\ \textit{reg}_2\texttt{)} &amp; \textit{seq}_1 \\
&amp; \textit{seq}_2 &amp; \textit{seq}_2 &amp; \texttt{(restore}\ \textit{reg}_1\texttt{)} \\
&amp; &amp; &amp; \texttt{(restore}\ \textit{reg}_2\texttt{)} \\
&amp; &amp; &amp; \textit{seq}_2
\end{array}
\]
</SCHEME>
<JAVASCRIPT>
<LATEX>
Expand All @@ -525,7 +534,7 @@ go_to(reg("continue"))
&amp; \texttt{restore(}\textit{reg}_1\texttt{),} &amp; \texttt{restore(}\textit{reg}_2\texttt{),} &amp; \textit{seq}_1 \\
&amp; \textit{seq}_2 &amp; \textit{seq}_2 &amp; \texttt{restore(}\textit{reg}_1\texttt{),} \\
&amp; &amp; &amp; \texttt{restore(}\textit{reg}_2\texttt{),} \\
&amp; &amp; &amp; \textit{seq}_2
&amp; &amp; &amp; \textit{seq}_2
\end{array}
\]
</LATEX>
Expand Down
Loading