Skip to content

Commit 43e126e

Browse files
authored
prep for scheme json version (#1078)
1 parent 781eebb commit 43e126e

File tree

6 files changed

+80
-21
lines changed

6 files changed

+80
-21
lines changed

xml/chapter2/section3/subsection4.xml

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,7 @@ BACADAEAFABBAAAGAH</TD></TR></TABLE>
235235
there is only one node left, which is the root of the entire tree.
236236
Here is how the Huffman tree of figure<SPACE/><REF NAME="fig:huffman"/> was
237237
generated:
238-
<SPLIT>
239-
<SCHEME>
240-
<FIGURE src="img_tex/ch2_3_4-3.png"></FIGURE>
241-
</SCHEME>
242-
<JAVASCRIPT>
243-
<TABLE>
238+
<TABLE>
244239
<TR SINGLESPACE="yes">
245240
<TD>
246241
Initial leaves
@@ -305,9 +300,7 @@ BACADAEAFABBAAAGAH</TD></TR></TABLE>
305300
<LATEXINLINE>$\{$</LATEXINLINE>(<LATEXINLINE>$\{$</LATEXINLINE>A B C D E F G H<LATEXINLINE>$\}$</LATEXINLINE> 17)<LATEXINLINE>$\}$</LATEXINLINE>
306301
</TD>
307302
</TR>
308-
</TABLE>
309-
</JAVASCRIPT>
310-
</SPLIT>
303+
</TABLE>
311304
The algorithm does not always specify a unique tree, because there may
312305
not be unique smallest-weight nodes at each step. Also, the choice of
313306
the order in which the two nodes are merged (i.e., which will be the
@@ -1052,12 +1045,7 @@ equal(sample_tree,
10521045
<INDEX>rock songs, 1950s</INDEX>
10531046
rock songs. (Note that the <QUOTE>symbols</QUOTE> of an
10541047
<QUOTE>alphabet</QUOTE> need not be individual letters.)
1055-
<SPLIT>
1056-
<SCHEME>
1057-
<FIGURE src="img_tex/ch2_3_4-4.png"></FIGURE>
1058-
</SCHEME>
1059-
<JAVASCRIPT>
1060-
<TABLE>
1048+
<TABLE>
10611049
<TR SINGLESPACE="yes">
10621050
<TD>
10631051
A
@@ -1128,9 +1116,7 @@ equal(sample_tree,
11281116
<SPACE/><SPACE/>1
11291117
</TD>
11301118
</TR>
1131-
</TABLE>
1132-
</JAVASCRIPT>
1133-
</SPLIT>
1119+
</TABLE>
11341120
Use
11351121
<SPLITINLINE>
11361122
<SCHEME><SCHEMEINLINE>generate-huffman-tree</SCHEMEINLINE></SCHEME>

xml/chapter3/section1/subsection3.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,7 @@ paul_acc("withdraw", "rosebud")(50); // Withdraws 50, should return 40
10451045
</EXERCISE>
10461046

10471047
<EXERCISE>
1048+
<LABEL NAME="ex:3_8"/>
10481049
When we defined the evaluation model in
10491050
section<SPACE/><REF NAME="sec:evaluating-combinations"/>, we said that the
10501051
<INDEX>order of evaluation<SUBINDEX><ORDER>JavaScript</ORDER>in JavaScript</SUBINDEX></INDEX>

xml/chapter3/section2/section2.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,4 +303,7 @@
303303
<!-- Subsection 4 : Internal Definitions -->
304304
&amp;subsection3.2.4;
305305

306+
<!-- Subsection 5 : CSE Machine -->
307+
&amp;subsection3.2.5;
308+
306309
</SECTION>

xml/chapter3/section2/subsection5.xml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<SUBSECTION>
2+
<NAME>
3+
CSE Machine
4+
</NAME>
5+
6+
<LABEL NAME="sec:cse-machine"/>
7+
<INDEX>CSE machine<OPEN/></INDEX>
8+
9+
<SPLIT>
10+
<JAVASCRIPT>
11+
<TEXT>
12+
The environment model as presented so far focuses on how functions can refer
13+
to their parameters, locally declared names, and names that are declared
14+
outside the function. We achieve this by evaluating statements and expressions
15+
with respect to a <EM>current environment</EM>. It does not specify how
16+
we keep track of environments as computation proceeds. For example, when we
17+
evaluate an expression <JAVASCRIPTINLINE>f(x) + y</JAVASCRIPTINLINE>, we
18+
need to evaluate <JAVASCRIPTINLINE>x</JAVASCRIPTINLINE> in the current
19+
environment, establish as the new current environment the environment of
20+
<JAVASCRIPTINLINE>f</JAVASCRIPTINLINE> extended by a binding of its
21+
parameter to the value of <JAVASCRIPTINLINE>x</JAVASCRIPTINLINE>, and
22+
evaluate the body of <JAVASCRIPTINLINE>f</JAVASCRIPTINLINE> in this
23+
extended environment. But what environment should we use for evaluating
24+
<JAVASCRIPTINLINE>y</JAVASCRIPTINLINE> after
25+
<JAVASCRIPTINLINE>f</JAVASCRIPTINLINE> returns?
26+
In this section, we extend the
27+
</TEXT>
28+
29+
<SUBHEADING><NAME>Evaluating arithmetic expressions</NAME></SUBHEADING>
30+
31+
<TEXT>
32+
Exercise<SPACE/><REF NAME="ex:3_8"/> shows that the presence of
33+
assignments makes the result of a program depend on the order in which
34+
the operands of an operator combination are evaluated. To remove
35+
ambiguities that arise from this, the JavaScript standard specifies
36+
left-to-right evaluation of operands.
37+
38+
As an example, consider the evaluation of the arithmetic expression statement
39+
<SNIPPET>
40+
<JAVASCRIPT>
41+
1 + (2 * 3);
42+
</JAVASCRIPT>
43+
</SNIPPET>
44+
The expression is decomposed into its operands
45+
<JAVASCRIPTINLINE>1</JAVASCRIPTINLINE> and
46+
<JAVASCRIPTINLINE>2 * 3</JAVASCRIPTINLINE>, followed by the
47+
<EM>instruction</EM> to add their results.
48+
</TEXT>
49+
<INDEX>CSE machine<CLOSE/></INDEX>
50+
</JAVASCRIPT>
51+
</SPLIT>
52+
</SUBSECTION>

xml/chapter3/section5/subsection2.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,15 @@ const fibs = pair(0,
578578
by adding <SCHEMEINLINE>fibs</SCHEMEINLINE> to itself shifted by one place:
579579
<SPLIT>
580580
<SCHEME>
581-
<FIGURE src="img_tex/ch3_5_2-1.png"></FIGURE>
581+
<LATEX>
582+
\[
583+
\begin{array}{ccccccccccccl}
584+
&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)} \\
585+
&amp; &amp; 0 &amp; 1 &amp; 1 &amp; 2 &amp; 3 &amp; 5 &amp; 8 &amp; 13 &amp; \ldots &amp; = &amp; \texttt{fibs} \\ \hline
586+
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}
587+
\end{array}
588+
\]
589+
</LATEX>
582590
</SCHEME>
583591
<JAVASCRIPT>
584592
<LATEX>

xml/chapter5/section5/subsection1.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,16 @@ go_to(reg("continue"))
514514
<!-- %Whew! What a pain it was to set this, because of the blank lines. -->
515515
<SPLIT>
516516
<SCHEME>
517-
<FIGURE src="img_original/preserving_table.svg"></FIGURE>
517+
\[
518+
\begin{array}{l|l|l|l}
519+
\textit{seq}_1 &amp; \texttt{(save}\ \textit{reg}_1\texttt{)} &amp; \texttt{(save}\ \textit{reg}_2\texttt{)} &amp; \texttt{(save}\ \textit{reg}_2\texttt{)} \\
520+
\textit{seq}_2 &amp; \textit{seq}_1 &amp; \textit{seq}_1 &amp; \texttt{(save}\ \textit{reg}_1\texttt{)} \\
521+
&amp; \texttt{(restore}\ \textit{reg}_1\texttt{)} &amp; \texttt{(restore}\ \textit{reg}_2\texttt{)} &amp; \textit{seq}_1 \\
522+
&amp; \textit{seq}_2 &amp; \textit{seq}_2 &amp; \texttt{(restore}\ \textit{reg}_1\texttt{)} \\
523+
&amp; &amp; &amp; \texttt{(restore}\ \textit{reg}_2\texttt{)} \\
524+
&amp; &amp; &amp; \textit{seq}_2
525+
\end{array}
526+
\]
518527
</SCHEME>
519528
<JAVASCRIPT>
520529
<LATEX>
@@ -525,7 +534,7 @@ go_to(reg("continue"))
525534
&amp; \texttt{restore(}\textit{reg}_1\texttt{),} &amp; \texttt{restore(}\textit{reg}_2\texttt{),} &amp; \textit{seq}_1 \\
526535
&amp; \textit{seq}_2 &amp; \textit{seq}_2 &amp; \texttt{restore(}\textit{reg}_1\texttt{),} \\
527536
&amp; &amp; &amp; \texttt{restore(}\textit{reg}_2\texttt{),} \\
528-
&amp; &amp; &amp; \textit{seq}_2
537+
&amp; &amp; &amp; \textit{seq}_2
529538
\end{array}
530539
\]
531540
</LATEX>

0 commit comments

Comments
 (0)