-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbook-Z-H-4.html
173 lines (166 loc) · 20.3 KB
/
book-Z-H-4.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<!-- Generated from TeX source by tex2page, v 4n,
(c) Dorai Sitaram, http://www.cs.rice.edu/~dorai/tex2page -->
<head>
<title>
Structure and Interpretation
of Computer Programs
</title>
<link rel="stylesheet" type="text/css" href="book-Z-C.css" title=default>
<meta name=robots content="noindex,follow">
</head>
<body>
<p><div class=navigation>[Go to <a href="book.html">first</a>,
<a href="book-Z-H-3.html">previous</a>,
<a href="book-Z-H-5.html">next</a> page; <a href="book-Z-H-38.html#%_index_start">index</a>]</div><p>
<a name="%_chap_IGNORE"></a>
<h1 class=chapter>
<div class=chapterheading> </div><p>
Contents</h1><p>
<a name="%_toc_start"><p><b>
<a name="%_toc_%_chap_IGNORE" href="book-Z-H-5.html#%_chap_IGNORE">Foreword</a></b><br>
<p><b>
<a name="%_toc_%_chap_IGNORE" href="book-Z-H-6.html#%_chap_IGNORE">Preface to the Second Edition</a></b><br>
<p><b>
<a name="%_toc_%_chap_IGNORE" href="book-Z-H-7.html#%_chap_IGNORE">Preface to the First Edition</a></b><br>
<p><b>
<a name="%_toc_%_chap_IGNORE" href="book-Z-H-8.html#%_chap_IGNORE">Acknowledgments</a></b><br>
<p><b>
<a name="%_toc_%_chap_1" href="book-Z-H-9.html#%_chap_1">1 Building Abstractions with Procedures</a></b><br>
<a name="%_toc_%_sec_1.1" href="book-Z-H-10.html#%_sec_1.1">1.1 The Elements of Programming</a><br>
<a name="%_toc_%_sec_1.1.1" href="book-Z-H-10.html#%_sec_1.1.1">1.1.1 Expressions</a><br>
<a name="%_toc_%_sec_1.1.2" href="book-Z-H-10.html#%_sec_1.1.2">1.1.2 Naming and the Environment</a><br>
<a name="%_toc_%_sec_1.1.3" href="book-Z-H-10.html#%_sec_1.1.3">1.1.3 Evaluating Combinations</a><br>
<a name="%_toc_%_sec_1.1.4" href="book-Z-H-10.html#%_sec_1.1.4">1.1.4 Compound Procedures</a><br>
<a name="%_toc_%_sec_1.1.5" href="book-Z-H-10.html#%_sec_1.1.5">1.1.5 The Substitution Model for Procedure Application</a><br>
<a name="%_toc_%_sec_1.1.6" href="book-Z-H-10.html#%_sec_1.1.6">1.1.6 Conditional Expressions and Predicates</a><br>
<a name="%_toc_%_sec_1.1.7" href="book-Z-H-10.html#%_sec_1.1.7">1.1.7 Example: Square Roots by Newton's Method</a><br>
<a name="%_toc_%_sec_1.1.8" href="book-Z-H-10.html#%_sec_1.1.8">1.1.8 Procedures as Black-Box Abstractions</a><br>
<a name="%_toc_%_sec_1.2" href="book-Z-H-11.html#%_sec_1.2">1.2 Procedures and the Processes They Generate</a><br>
<a name="%_toc_%_sec_1.2.1" href="book-Z-H-11.html#%_sec_1.2.1">1.2.1 Linear Recursion and Iteration</a><br>
<a name="%_toc_%_sec_1.2.2" href="book-Z-H-11.html#%_sec_1.2.2">1.2.2 Tree Recursion</a><br>
<a name="%_toc_%_sec_1.2.3" href="book-Z-H-11.html#%_sec_1.2.3">1.2.3 Orders of Growth</a><br>
<a name="%_toc_%_sec_1.2.4" href="book-Z-H-11.html#%_sec_1.2.4">1.2.4 Exponentiation</a><br>
<a name="%_toc_%_sec_1.2.5" href="book-Z-H-11.html#%_sec_1.2.5">1.2.5 Greatest Common Divisors</a><br>
<a name="%_toc_%_sec_1.2.6" href="book-Z-H-11.html#%_sec_1.2.6">1.2.6 Example: Testing for Primality</a><br>
<a name="%_toc_%_sec_1.3" href="book-Z-H-12.html#%_sec_1.3">1.3 Formulating Abstractions with Higher-Order Procedures</a><br>
<a name="%_toc_%_sec_1.3.1" href="book-Z-H-12.html#%_sec_1.3.1">1.3.1 Procedures as Arguments</a><br>
<a name="%_toc_%_sec_1.3.2" href="book-Z-H-12.html#%_sec_1.3.2">1.3.2 Constructing Procedures Using <tt>Lambda</tt></a><br>
<a name="%_toc_%_sec_1.3.3" href="book-Z-H-12.html#%_sec_1.3.3">1.3.3 Procedures as General Methods</a><br>
<a name="%_toc_%_sec_1.3.4" href="book-Z-H-12.html#%_sec_1.3.4">1.3.4 Procedures as Returned Values</a><br>
<p><b>
<a name="%_toc_%_chap_2" href="book-Z-H-13.html#%_chap_2">2 Building Abstractions with Data</a></b><br>
<a name="%_toc_%_sec_2.1" href="book-Z-H-14.html#%_sec_2.1">2.1 Introduction to Data Abstraction</a><br>
<a name="%_toc_%_sec_2.1.1" href="book-Z-H-14.html#%_sec_2.1.1">2.1.1 Example: Arithmetic Operations for Rational Numbers</a><br>
<a name="%_toc_%_sec_2.1.2" href="book-Z-H-14.html#%_sec_2.1.2">2.1.2 Abstraction Barriers</a><br>
<a name="%_toc_%_sec_2.1.3" href="book-Z-H-14.html#%_sec_2.1.3">2.1.3 What Is Meant by Data?</a><br>
<a name="%_toc_%_sec_2.1.4" href="book-Z-H-14.html#%_sec_2.1.4">2.1.4 Extended Exercise: Interval Arithmetic</a><br>
<a name="%_toc_%_sec_2.2" href="book-Z-H-15.html#%_sec_2.2">2.2 Hierarchical Data and the Closure Property</a><br>
<a name="%_toc_%_sec_2.2.1" href="book-Z-H-15.html#%_sec_2.2.1">2.2.1 Representing Sequences</a><br>
<a name="%_toc_%_sec_2.2.2" href="book-Z-H-15.html#%_sec_2.2.2">2.2.2 Hierarchical Structures</a><br>
<a name="%_toc_%_sec_2.2.3" href="book-Z-H-15.html#%_sec_2.2.3">2.2.3 Sequences as Conventional Interfaces</a><br>
<a name="%_toc_%_sec_2.2.4" href="book-Z-H-15.html#%_sec_2.2.4">2.2.4 Example: A Picture Language</a><br>
<a name="%_toc_%_sec_2.3" href="book-Z-H-16.html#%_sec_2.3">2.3 Symbolic Data</a><br>
<a name="%_toc_%_sec_2.3.1" href="book-Z-H-16.html#%_sec_2.3.1">2.3.1 Quotation</a><br>
<a name="%_toc_%_sec_2.3.2" href="book-Z-H-16.html#%_sec_2.3.2">2.3.2 Example: Symbolic Differentiation</a><br>
<a name="%_toc_%_sec_2.3.3" href="book-Z-H-16.html#%_sec_2.3.3">2.3.3 Example: Representing Sets</a><br>
<a name="%_toc_%_sec_2.3.4" href="book-Z-H-16.html#%_sec_2.3.4">2.3.4 Example: Huffman Encoding Trees</a><br>
<a name="%_toc_%_sec_2.4" href="book-Z-H-17.html#%_sec_2.4">2.4 Multiple Representations for Abstract Data</a><br>
<a name="%_toc_%_sec_2.4.1" href="book-Z-H-17.html#%_sec_2.4.1">2.4.1 Representations for Complex Numbers</a><br>
<a name="%_toc_%_sec_2.4.2" href="book-Z-H-17.html#%_sec_2.4.2">2.4.2 Tagged data</a><br>
<a name="%_toc_%_sec_2.4.3" href="book-Z-H-17.html#%_sec_2.4.3">2.4.3 Data-Directed Programming and Additivity</a><br>
<a name="%_toc_%_sec_2.5" href="book-Z-H-18.html#%_sec_2.5">2.5 Systems with Generic Operations</a><br>
<a name="%_toc_%_sec_2.5.1" href="book-Z-H-18.html#%_sec_2.5.1">2.5.1 Generic Arithmetic Operations</a><br>
<a name="%_toc_%_sec_2.5.2" href="book-Z-H-18.html#%_sec_2.5.2">2.5.2 Combining Data of Different Types</a><br>
<a name="%_toc_%_sec_2.5.3" href="book-Z-H-18.html#%_sec_2.5.3">2.5.3 Example: Symbolic Algebra</a><br>
<p><b>
<a name="%_toc_%_chap_3" href="book-Z-H-19.html#%_chap_3">3 Modularity, Objects, and State</a></b><br>
<a name="%_toc_%_sec_3.1" href="book-Z-H-20.html#%_sec_3.1">3.1 Assignment and Local State</a><br>
<a name="%_toc_%_sec_3.1.1" href="book-Z-H-20.html#%_sec_3.1.1">3.1.1 Local State Variables</a><br>
<a name="%_toc_%_sec_3.1.2" href="book-Z-H-20.html#%_sec_3.1.2">3.1.2 The Benefits of Introducing Assignment</a><br>
<a name="%_toc_%_sec_3.1.3" href="book-Z-H-20.html#%_sec_3.1.3">3.1.3 The Costs of Introducing Assignment</a><br>
<a name="%_toc_%_sec_3.2" href="book-Z-H-21.html#%_sec_3.2">3.2 The Environment Model of Evaluation</a><br>
<a name="%_toc_%_sec_3.2.1" href="book-Z-H-21.html#%_sec_3.2.1">3.2.1 The Rules for Evaluation</a><br>
<a name="%_toc_%_sec_3.2.2" href="book-Z-H-21.html#%_sec_3.2.2">3.2.2 Applying Simple Procedures</a><br>
<a name="%_toc_%_sec_3.2.3" href="book-Z-H-21.html#%_sec_3.2.3">3.2.3 Frames as the Repository of Local State</a><br>
<a name="%_toc_%_sec_3.2.4" href="book-Z-H-21.html#%_sec_3.2.4">3.2.4 Internal Definitions</a><br>
<a name="%_toc_%_sec_3.3" href="book-Z-H-22.html#%_sec_3.3">3.3 Modeling with Mutable Data</a><br>
<a name="%_toc_%_sec_3.3.1" href="book-Z-H-22.html#%_sec_3.3.1">3.3.1 Mutable List Structure</a><br>
<a name="%_toc_%_sec_3.3.2" href="book-Z-H-22.html#%_sec_3.3.2">3.3.2 Representing Queues</a><br>
<a name="%_toc_%_sec_3.3.3" href="book-Z-H-22.html#%_sec_3.3.3">3.3.3 Representing Tables</a><br>
<a name="%_toc_%_sec_3.3.4" href="book-Z-H-22.html#%_sec_3.3.4">3.3.4 A Simulator for Digital Circuits</a><br>
<a name="%_toc_%_sec_3.3.5" href="book-Z-H-22.html#%_sec_3.3.5">3.3.5 Propagation of Constraints</a><br>
<a name="%_toc_%_sec_3.4" href="book-Z-H-23.html#%_sec_3.4">3.4 Concurrency: Time Is of the Essence</a><br>
<a name="%_toc_%_sec_3.4.1" href="book-Z-H-23.html#%_sec_3.4.1">3.4.1 The Nature of Time in Concurrent Systems</a><br>
<a name="%_toc_%_sec_3.4.2" href="book-Z-H-23.html#%_sec_3.4.2">3.4.2 Mechanisms for Controlling Concurrency</a><br>
<a name="%_toc_%_sec_3.5" href="book-Z-H-24.html#%_sec_3.5">3.5 Streams</a><br>
<a name="%_toc_%_sec_3.5.1" href="book-Z-H-24.html#%_sec_3.5.1">3.5.1 Streams Are Delayed Lists</a><br>
<a name="%_toc_%_sec_3.5.2" href="book-Z-H-24.html#%_sec_3.5.2">3.5.2 Infinite Streams</a><br>
<a name="%_toc_%_sec_3.5.3" href="book-Z-H-24.html#%_sec_3.5.3">3.5.3 Exploiting the Stream Paradigm</a><br>
<a name="%_toc_%_sec_3.5.4" href="book-Z-H-24.html#%_sec_3.5.4">3.5.4 Streams and Delayed Evaluation</a><br>
<a name="%_toc_%_sec_3.5.5" href="book-Z-H-24.html#%_sec_3.5.5">3.5.5 Modularity of Functional Programs and Modularity of Objects</a><br>
<p><b>
<a name="%_toc_%_chap_4" href="book-Z-H-25.html#%_chap_4">4 Metalinguistic Abstraction</a></b><br>
<a name="%_toc_%_sec_4.1" href="book-Z-H-26.html#%_sec_4.1">4.1 The Metacircular Evaluator</a><br>
<a name="%_toc_%_sec_4.1.1" href="book-Z-H-26.html#%_sec_4.1.1">4.1.1 The Core of the Evaluator</a><br>
<a name="%_toc_%_sec_4.1.2" href="book-Z-H-26.html#%_sec_4.1.2">4.1.2 Representing Expressions</a><br>
<a name="%_toc_%_sec_4.1.3" href="book-Z-H-26.html#%_sec_4.1.3">4.1.3 Evaluator Data Structures</a><br>
<a name="%_toc_%_sec_4.1.4" href="book-Z-H-26.html#%_sec_4.1.4">4.1.4 Running the Evaluator as a Program</a><br>
<a name="%_toc_%_sec_4.1.5" href="book-Z-H-26.html#%_sec_4.1.5">4.1.5 Data as Programs</a><br>
<a name="%_toc_%_sec_4.1.6" href="book-Z-H-26.html#%_sec_4.1.6">4.1.6 Internal Definitions</a><br>
<a name="%_toc_%_sec_4.1.7" href="book-Z-H-26.html#%_sec_4.1.7">4.1.7 Separating Syntactic Analysis from Execution</a><br>
<a name="%_toc_%_sec_4.2" href="book-Z-H-27.html#%_sec_4.2">4.2 Variations on a Scheme -- Lazy Evaluation</a><br>
<a name="%_toc_%_sec_4.2.1" href="book-Z-H-27.html#%_sec_4.2.1">4.2.1 Normal Order and Applicative Order</a><br>
<a name="%_toc_%_sec_4.2.2" href="book-Z-H-27.html#%_sec_4.2.2">4.2.2 An Interpreter with Lazy Evaluation</a><br>
<a name="%_toc_%_sec_4.2.3" href="book-Z-H-27.html#%_sec_4.2.3">4.2.3 Streams as Lazy Lists</a><br>
<a name="%_toc_%_sec_4.3" href="book-Z-H-28.html#%_sec_4.3">4.3 Variations on a Scheme -- Nondeterministic Computing</a><br>
<a name="%_toc_%_sec_4.3.1" href="book-Z-H-28.html#%_sec_4.3.1">4.3.1 Amb and Search</a><br>
<a name="%_toc_%_sec_4.3.2" href="book-Z-H-28.html#%_sec_4.3.2">4.3.2 Examples of Nondeterministic Programs</a><br>
<a name="%_toc_%_sec_4.3.3" href="book-Z-H-28.html#%_sec_4.3.3">4.3.3 Implementing the <tt>Amb</tt> Evaluator</a><br>
<a name="%_toc_%_sec_4.4" href="book-Z-H-29.html#%_sec_4.4">4.4 Logic Programming</a><br>
<a name="%_toc_%_sec_4.4.1" href="book-Z-H-29.html#%_sec_4.4.1">4.4.1 Deductive Information Retrieval</a><br>
<a name="%_toc_%_sec_4.4.2" href="book-Z-H-29.html#%_sec_4.4.2">4.4.2 How the Query System Works</a><br>
<a name="%_toc_%_sec_4.4.3" href="book-Z-H-29.html#%_sec_4.4.3">4.4.3 Is Logic Programming Mathematical Logic?</a><br>
<a name="%_toc_%_sec_4.4.4" href="book-Z-H-29.html#%_sec_4.4.4">4.4.4 Implementing the Query System</a><br>
<p><b>
<a name="%_toc_%_chap_5" href="book-Z-H-30.html#%_chap_5">5 Computing with Register Machines</a></b><br>
<a name="%_toc_%_sec_5.1" href="book-Z-H-31.html#%_sec_5.1">5.1 Designing Register Machines</a><br>
<a name="%_toc_%_sec_5.1.1" href="book-Z-H-31.html#%_sec_5.1.1">5.1.1 A Language for Describing Register Machines</a><br>
<a name="%_toc_%_sec_5.1.2" href="book-Z-H-31.html#%_sec_5.1.2">5.1.2 Abstraction in Machine Design</a><br>
<a name="%_toc_%_sec_5.1.3" href="book-Z-H-31.html#%_sec_5.1.3">5.1.3 Subroutines</a><br>
<a name="%_toc_%_sec_5.1.4" href="book-Z-H-31.html#%_sec_5.1.4">5.1.4 Using a Stack to Implement Recursion</a><br>
<a name="%_toc_%_sec_5.1.5" href="book-Z-H-31.html#%_sec_5.1.5">5.1.5 Instruction Summary</a><br>
<a name="%_toc_%_sec_5.2" href="book-Z-H-32.html#%_sec_5.2">5.2 A Register-Machine Simulator</a><br>
<a name="%_toc_%_sec_5.2.1" href="book-Z-H-32.html#%_sec_5.2.1">5.2.1 The Machine Model</a><br>
<a name="%_toc_%_sec_5.2.2" href="book-Z-H-32.html#%_sec_5.2.2">5.2.2 The Assembler</a><br>
<a name="%_toc_%_sec_5.2.3" href="book-Z-H-32.html#%_sec_5.2.3">5.2.3 Generating Execution Procedures for Instructions</a><br>
<a name="%_toc_%_sec_5.2.4" href="book-Z-H-32.html#%_sec_5.2.4">5.2.4 Monitoring Machine Performance</a><br>
<a name="%_toc_%_sec_5.3" href="book-Z-H-33.html#%_sec_5.3">5.3 Storage Allocation and Garbage Collection</a><br>
<a name="%_toc_%_sec_5.3.1" href="book-Z-H-33.html#%_sec_5.3.1">5.3.1 Memory as Vectors</a><br>
<a name="%_toc_%_sec_5.3.2" href="book-Z-H-33.html#%_sec_5.3.2">5.3.2 Maintaining the Illusion of Infinite Memory</a><br>
<a name="%_toc_%_sec_5.4" href="book-Z-H-34.html#%_sec_5.4">5.4 The Explicit-Control Evaluator</a><br>
<a name="%_toc_%_sec_5.4.1" href="book-Z-H-34.html#%_sec_5.4.1">5.4.1 The Core of the Explicit-Control Evaluator</a><br>
<a name="%_toc_%_sec_5.4.2" href="book-Z-H-34.html#%_sec_5.4.2">5.4.2 Sequence Evaluation and Tail Recursion</a><br>
<a name="%_toc_%_sec_5.4.3" href="book-Z-H-34.html#%_sec_5.4.3">5.4.3 Conditionals, Assignments, and Definitions</a><br>
<a name="%_toc_%_sec_5.4.4" href="book-Z-H-34.html#%_sec_5.4.4">5.4.4 Running the Evaluator</a><br>
<a name="%_toc_%_sec_5.5" href="book-Z-H-35.html#%_sec_5.5">5.5 Compilation</a><br>
<a name="%_toc_%_sec_5.5.1" href="book-Z-H-35.html#%_sec_5.5.1">5.5.1 Structure of the Compiler</a><br>
<a name="%_toc_%_sec_5.5.2" href="book-Z-H-35.html#%_sec_5.5.2">5.5.2 Compiling Expressions</a><br>
<a name="%_toc_%_sec_5.5.3" href="book-Z-H-35.html#%_sec_5.5.3">5.5.3 Compiling Combinations</a><br>
<a name="%_toc_%_sec_5.5.4" href="book-Z-H-35.html#%_sec_5.5.4">5.5.4 Combining Instruction Sequences</a><br>
<a name="%_toc_%_sec_5.5.5" href="book-Z-H-35.html#%_sec_5.5.5">5.5.5 An Example of Compiled Code</a><br>
<a name="%_toc_%_sec_5.5.6" href="book-Z-H-35.html#%_sec_5.5.6">5.5.6 Lexical Addressing</a><br>
<a name="%_toc_%_sec_5.5.7" href="book-Z-H-35.html#%_sec_5.5.7">5.5.7 Interfacing Compiled Code to the Evaluator</a><br>
<p><b>
<a name="%_toc_%_chap_IGNORE" href="book-Z-H-36.html#%_chap_IGNORE">References</a></b><br>
<p><b>
<a name="%_toc_%_chap_IGNORE" href="book-Z-H-37.html#%_chap_IGNORE">List of Exercises</a></b><br>
<p><b>
<a name="%_toc_%_chap_IGNORE" href="book-Z-H-38.html#%_chap_IGNORE">Index</a></b><br>
<p>
<p><div class=navigation>[Go to <a href="book.html">first</a>,
<a href="book-Z-H-3.html">previous</a>,
<a href="book-Z-H-5.html">next</a> page; <a href="book-Z-H-38.html#%_index_start">index</a>]</div><p>
</body>
</html>