最终检查和拼写检查进行修正和调整 + % 1996年4月9日 根据与之前索引的对比进行微小修正 + % 1996年4月6日-... Julie 索引修正 (以及4月8日更改'ns') + % 1996年4月5日 Hal 索引 + % 1996年3月29日, 4月3日 Julie: 索引修正 + % 1996年3月18日 继续页码,其他索引的细微更改 + % 1996年3月14日 & 3月16日 已分页至第64页 (查找 \\pagekludge) + % 1996年3月10日-3月14日 细微更改/修正;索引;移动练习 + % 1996年3月9日 修正某些练习部分的空格 + % 1996年3月6日 修正排版错误 + % 1996年3月5日 细微排版修正 + % 1996年3月4日 编辑一等过程的脚注以适应 PSZ;修复小错误 + % 1996年2月26日至3月1日 修复一些坏的换行 + % 1996年2月24日 在 {lisp} 后冲洗 \\noindent,通过关闭空格 % + % 1996年2月24日 修复 GCD-简化方程的格式 + % 1996年2月23日 使用新的 smallequation 宏修复排版 + % 1996年2月22日 epigraph的新规范 + % 1996年2月21日 修复绝对值定义的格式 + % 1996年2月20日 修复箭头的绘制方式 + % 1996年2月19日 更改 exp-iter -> expt-iter,fast-exp -> fast-expt + % 1996年2月19日 修复引用中的 () + % 1996年2月19日 修复 et al. +
Recursive Functions of Symbolic Expressions and Their + Computation by Machine(
JavaScript是 Oracle Corporation 的商标。 +
officialdefinition of the language. This evolution, + together with the flexibility and elegance of the initial conception, + has enabled Lisp, which is the second oldest language in widespread use + today (only +
passivedata and
active+ processes. As we + shall discover, Lisp
东西,而 +
简单数据的这一表征是一种赤裸裸的虚张声势。事实上,对于任何编程语言来说,数字处理是最棘手且最令人困惑的方面之一。一些典型的问题包括: +
运行按钮来求值该语句。 + 点击原语表达式语句,看看会发生什么! +
Lisp 程序员知道一切的价值,但不知道任何的成本。
显示依赖项。 + 因此,点击 + +
显示依赖项后,您将看到: + +
值)关联,从而将第二条规则视为第三条规则的特殊情况。 +
语法糖会导致分号的癌症。
平方+ 我们可以这样说, +
要使一个数平方,将它乘以它本身。+
要使一个数平方,把它与其自身相乘。+
槽。
意义+ 的 +
代换,用于 +
可变数据时,我们将看到代换模型失效,必须被更复杂的模型所替代,用于 +
完全展开然后化简求值方法称为 +
评估参数然后应用方法形成对比,后者称为 +
非法。) + +
无穷的数据结构的方法。在
conditional), and it is used as follows: +
Interpreted as either ++ means this: In Scheme, there are two distinguished values that are + denoted by the constants +true +false ++ \#t + true + \#f + true or false false
如果+ 条件表达式的一般形式是 +$x$ 大于等于零,则返回$x$ ;否则返回$- x$ 。
减号操作符
如果+$x$ 小于零 + 返回$- x$ ;否则返回 +$x$ 。
正确+ ,就是对程序做出一个声明式的陈述。 + 有大量研究旨在建立证明程序正确的技术,并且该领域技术难点主要在于协调 + 命令式陈述(程序构造的基础)和声明式陈述(可用于推导)的转变。 +
是什么知识基础上, + 它们能够自动生成
如何做的知识。这在一般情况下无法实现,但在某些重要领域已取得进展。 + 我们将在第
尾递归部分在 + 节中的相关说明。
循环定义根本无法成立,更不用说指定一个由计算机执行的明确定义的过程了。这将在章节
黑盒子。我们在那时并不关心这个 + 如何计算结果, +
形态。我们还将研究这些过程消耗重要计算资源——时间和空间的速率。 + 我们将考虑的 +
“形状”时,我们发现它们的发展方式却截然不同。 +
隐藏的信息,这些信息不包含在状态变量中, + 它表明了在处理一连串延迟操作时
过程所处的位置。 + 链越长,必须维护的信息就越多。
循环结构来描述迭代过程,例如 +
消息传递计算模型中解释了它。受此启发,杰拉尔德·杰伊·萨斯曼 + 和 +
消息传递计算模型中解释了它。受此启发,杰拉尔德·杰伊·萨斯曼 + 和 +
语法糖导致分号癌症。+
+ 使用 ++$n$ 种硬币换取金额$a$ 的方法数等于 ++
+- + 使用除了第一种硬币以外的所有硬币换取金额
+$a$ 的方法数,加上 +- + 使用所有
+$n$ 种硬币换取金额$a-d$ 的方法数, + 其中$d$ 是第一种硬币的面值。 +
智能编译器+ 来同时获得两者的优点,该编译器可以将树形递归 +
),如果存在两个与 +$f(n)$ 的theta
机器操作,我们假设执行乘法操作所需的机器操作数与被乘数的大小无关,但当数字足够大时,这一假设是不成立的。对于空间估计,也有类似的说明。就像过程的设计和描述一样,过程的分析可以在不同的抽象层次上进行。
足够小。)这些思想体现在以下 +
俄国农民法乘法,历史悠久。其使用实例见于 +
+ 拉姆定理: +++ 如果欧几里得算法 + 计算某对数的最大公约数需要 拉姆 拉姆定理$k$ 步,那么该对中的较小数字必须大于或等于第 +$k$ 个斐波那契数。该定理由 + ++ 于1845年证明,他是 + 一位法国数学家和工程师,主要以对数学物理学的贡献闻名。为证明该定理,我们考虑满足 + 拉姆 加布里埃尔·拉姆$a_k\geq b_k$ ,且欧几里得算法在 +$k$ 步后终止的数对$(a_k, b_k)$ 。证法基于下面的断言: + 若 +$(a_{k+1}, b_{k+1}) \rightarrow (a_k, b_k) \rightarrow (a_{k-1}, b_{k-1})$ 是约简过程中的连续三对, + 则必须有 +$b_{k+1} \geq b_k + b_{k-1}$ 。 + 验证该断言时,考虑约简步骤定义为应用变换 +$a_{k-1} = b_k$ 以及 +$b_{k-1} = a_k\ \textrm{除以}\ b_k\ \textrm{的余数}$ 。 + 第二个等式意味着 +$a_k = q b_k + b_{k-1}$ ,其中 +$q$ 为某个正整数。由于 +$q \geq 1$ ,则有 +$a_k = q b_k + b_{k-1} \geq b_k + b_{k-1}$ 。 + 在前一步约简中,$b_{k+1} = a_k$ ,因此, +$b_{k+1} = a_k \geq b_k + b_{k-1}$ 。 + 这验证了该断言。现在我们可以对算法终止所用步数 +$k$ 做归纳证明该定理。对于 +$k=1$ ,结果显然成立,因为这仅要求 +$b$ 至少等于 +$\text{Fib}(1)=1$ 。假设该结果对所有小于或等于 +$k$ 的整数成立,现对 +$k+1$ 进行证明。设 +$(a_{k+1}, b_{k+1}) \rightarrow (a_k, b_k) \rightarrow (a_{k-1}, b_{k-1})$ 为约简过程中的连续数对。 + 由归纳假设有 +$b_{k-1} \geq \textrm{Fib}(k-1)$ 且 +$b_k \geq \textrm{Fib}(k)$ 。因此,结合已证断言和斐波那契数的定义, + 有 +$b_{k+1} \geq b_k + b_{k-1} \geq \textrm{Fib}(k) + \textrm{Fib}(k-1) = \textrm{Fib}(k+1)$ , + 证毕拉姆定理。
概率算法,增长阶为
我发现了一个真正卓越的证明,但此边空太小,无法容纳。。寻找费马大定理的证明成为数论中最著名的挑战之一。1995年 +
+ 费马小定理: ++ (两个数被称为 ++ 如果 费马小定理 费马小定理$n$ 是素数,且 +$a$ 是任何小于 +$n$ 的正整数,那么$a$ 的 +$n$ 次幂模 +$n$ 余数与 +$a$ 相同。 +
正确算法时产生错误的概率还低。将算法认为因第一种原因而不充分,但因第二种原因却充分,体现了 +
不可破解的密码,由 +
模,即一个不等于1或$n$ 的 + 非平凡平方根
sigma + notation,for example +
slotsinto +
the procedure that returns its + input incremented by 4and
the procedure that returns the + reciprocal of its input times its input plus 2.We can do this + by introducing the special form
返回输入加 4 的函数和
返回其输入的倒数乘以输入加 2 的函数。我们可以通过引入 lambda 表达式 作为创建函数的语法形式来实现这一点。 + 使用 lambda 表达式,我们可以将我们想要的描述为 + +
lambda在
small enough). + Here is a +
close enoughwe can use a +
smallnumber to indicate a tolerance for the acceptable error + in a calculation. The appropriate tolerance for a real calculation depends + upon the problem to be solved and the limitations of the computer and the + algorithm. This is often + a very subtle consideration, requiring help from a +
maps to) is the mathematician
权利和特权包括:
最终检查和拼写检查进行更正和调整 + % 4/9 基于索引前的比较进行微小修复 + % 4/7-... Julie 索引修正 (以及4/8更改 'ns') + % 4/6/96 Julie: 分页更改; 添加 Thatcher 参考; 索引修正 + % 4/5/96 Hal 索引 + % 4/5/96 Julie: 索引修正; 排版错误修复 + % 4/4/96 内容修正; 分页调整; 剩余分页 + % 4/3/96 索引更改 + % 4/2/96 分页至2.2 + % 4/1/96 Julie: 分页至 Rogers 注脚 + % 4/1/96 Julie 杂项改进 + % 3/29/96 Julie 索引修正 + % 3/20/96 Julie 索引修正 + % 3/18/96 'atan' 编辑 & 微小的索引修正 + % 3/17/96 Julie 微小索引更改 + % 3/15/96 Julie 微小索引更改 + % 3/10-3/13/96 Hal 索引,Julie 的微小索引修正/添加 + + % 3/9/96 修复某些习题部分中的空格; 将行划分为get/put规范; + % 其他微小编辑 + % 3/6/96 微小词语和换行改进 + % 3/4/96 改写以'修复'大多数三重连字符; 其他排版 + % 修复 + % 3/3/96 将countleaves更改为count-leaves(使其适应) + % 3/3/96 修复由Albert Meyer指出的多项式gcd注脚中的错误 + % 2/26-3/2/96 修复一些不良的换行 + % 2/24/96 在 {lisp} 后列出 \noindent 关闭空间以 + % 2/24/96 修复松散的注脚 (#49) + % 2/23/96 将8皇后图移入示例以避免多余的示例间距 + % 2/22/96 新的题词规范 + % 2/21/96 修正表格格式 + % 2/19/96 修正参考中的 () +
粘合在一起+ 一个分子和一个分母以形成一对
线性组合【40:8†cn.txt】 +
“一个 +的概念,我们很可能永远不会想定义像sum这样操作的可能性。此外,就执行求和操作而言,项如何从更原始的操作构建的细节是无关紧要的。过程, ”函数,
粘合剂,以便数据对象可以组合形成更复杂的数据对象。有许多可能的粘合剂。实际上,我们会发现如何仅使用 +
数据操作来形成复合数据。这将进一步模糊 +
过程+
函数
数据之间的区别,正如在第
abstract data.That is, our programs should use data in such + a way as to make no assumptions about the data that are not strictly + necessary for performing the task at hand. At the same time, a +
concretedata representation is defined independent of the + programs that use the data. The interface between these two parts of our + system will be a set of +
构造(constr)。 + 名称 +
地址和
减量部分。Car代表 +
寄存器地址部分的内容,而 cdr(发音
could-er) + 代表
寄存器减量部分的内容。
+ 以这种方式定义选择器和构造器是高效的: 而不是调用
+
+ 在本书中,我们选择不使用这种定义风格。 + +
+levelsof the system. At each level, the barrier + separates the programs (above) that use the data abstraction from the + programs (below) that implement the data abstraction. Programs that + use rational numbers manipulate them solely in terms of the +
for public useby the rational-number package: +
由给定的选择器和构造器实现的任何东西是不够的。显然,并非每一组三个
过程加条件
函数加条件
过程
函数
条件,并使用抽象代数的技术来检查关于数据对象的断言。这两种方法都在
这种观点不仅可以用来定义高级数据对象,如有理数,也可以用来定义低级对象。考虑一下
真实数据结构的实现区分开来。
+ +(原语函数) 过程实现 (原语函数) 函数实现 cdr? 提示:为了验证这个方法,请使用tail ?节的代换模型 。
6.8 ohms with 10% tolerance的电阻,您只能确定电阻在 $6.8-0.68=6.12$ 到 $6.8+0.68=7.48$ 欧姆之间。因此,如果您将 6.8 欧姆 10% 的电阻与 4.7 欧姆 5% 的电阻并联,其组合电阻可以从约 2.58 欧姆(如果两个电阻处于下限)到约 2.97 欧姆(如果两个电阻处于上限)。 +
gluethat we can + use to construct compound data objects. +
closurehere comes from abstract algebra, where a set of + elements is said to be + closed under an operation if applying the operation + to elements in the set produces an element that is again an element of the + set. The +
closureto + describe a totally unrelated concept: A closure + is an implementation technique for representing +
closurein this second sense in this + book.
In Pascal the + plethora of declarable data structures induces a specialization within + functions that inhibits and penalizes casual cooperation. It is better to + have 100 functions operate on one data structure than to have 10 functions + operate on 10 data structures.
nothing.
cdring down+ the lists. + +
cons up+ the heads and tails of an answer list while + cdring down a list, + +
signalconsisting of + the leaves of a given tree. This signal is passed through a +
transducerthat applies the + square +
signalsthat + flow from one stage in the process to the next. If we represent these + signals as lists, then we can use list operations to implement the + processing at each of the stages. For instance, we can implement the + mapping stages of the signal-flow diagrams using the + map +
+ |
+
+ returns the sum |
+
+ |
+
+ returns the vector |
+
+ |
+
+ returns the matrix |
+
+ |
+
+ returns the matrix |
+
pair
eight-queens puzzleasks how to place eight queens on a + chessboard so that no queen is in check from any other (i.e., no two + queens are in the same row, column, or diagonal). One possible solution + is shown in figure
Square Limitwoodcut (see +
polytechnic institute,and + served as Massachusetts
useful learning+ that was different from the university education of the time, with its + overemphasis on the classics, which, as he wrote,
stand in the + way of the broader, higher and more practical instruction and + discipline of the natural and social sciences.This + education was likewise to be different from narrow trade-school + education. In Rogers
+ The world-enforced distinction between the practical and the + scientific worker is utterly futile, and the whole experience of + modern times has demonstrated its utter worthlessness. ++ Rogers served as president of MIT until 1870, when he resigned due to + ill health. In 1878 the second president of MIT, +
++ In the words of Francis A. Walker +As I stand here today and see what the Institute is,+ +I call + to mind the beginnings of science. I remember one hundred and fifty + years ago Stephen Hales published a pamphlet on the subject of + illuminating gas, in which he stated that his researches had + demonstrated that 128 grains of bituminous coal coal, bituminous +Bituminous coal,these were his last words on + earth. Here he bent forward, as if consulting some notes on the + table before him, then slowly regaining an erect position, threw + up his hands, and was translated from the scene of his earthly + labors and triumphs tothe tomorrow of death,+ where the mysteries of life are solved, and the disembodied + spirit finds unending satisfaction in contemplating the new and + still unfathomable mysteries of the infinite future. +
+ All his life he had borne himself most faithfully and heroically, + and he died as so good a knight would surely have wished, in + harness, at his post, and in the very part and act of public duty. ++
Xby connecting opposite corners of + the frame. +
Xby connecting opposite + corners of the frame. +
Johnis clearly
J.If we tell somebody +
say your name aloud,we expect to hear that + person
saywe expect to hear + the wordsyour namealoud,
your name.Note that we are forced to nest + quotation marks to describe what somebody else might + say.
threeis + not the phrase
one plus two.Quotation is powerful + because it gives us a way to build expressions that manipulate other + expressions (as we will see when we write an interpreter in + chapter
equals can be + substituted for equalsshould mean. For example, if we know + that +
the + evening star is Venuswe can deduce
the morning star is + Venus.However, given that
John knows that the evening + star is Venuswe cannot infer that
John knows that the + morning star is Venus.
the sameif they consist of the same characters in the + same order. Such a definition skirts a deep issue that we are not yet + ready to address: the meaning of
samenessin a + programming language. We will return to this in + chapter
相同,如果它们由相同顺序的相同字符组成。这样的定义暂时避开了一个我们尚未准备处理的深刻问题:在编程语言中
相同的意义。我们将在第
sums,
products,and +
variableswithout worrying about how these are to be + represented. Only afterward will we address the representation problem. +
+ |
+ + Is e a variable? + | +
+ |
+ + Are v1 and + v2 the same variable? + | +
+ |
+ + Is e a sum? + | +
+ |
+ + Addend of the sum e. + | +
+ |
+ + Augend of the sum e. + | +
+ |
+ + Construct the sum of a1 and + a2. + | +
+ |
+ + Is e a product? + | +
+ |
+ + Multiplier of the product e. + | +
+ |
+ + Multiplicand of the product e. + | +
+ |
+ + Construct the product of m1 and + m2. + | +
simplest.The problem + of algebraic simplification is complex because, among other reasons, a + form that may be simplest for one purpose may not be for another. +
setby specifying the +
consistent with the interpretations given aboveto mean + that the operations satisfy a collection of rules such as these: +
Adjoining an object to a set produces a + set that contains the object). +
The elements of +). ++ (union-set S T) + + are the elements that are in S or in + T+ union_set(S, T) +
No object is an element of the empty set). +
entryat that node, and a link to each + of two other (possibly empty) nodes. The
leftlink points to + elements smaller than the one at the node, and the
right+ link to elements greater than the one at the node. + Figure
balanced,each of these subtrees will be about half the size + of the original. Thus, in one step we have reduced the problem of + searching a tree of size
binary treefrom + the particular way we might wish to represent such a tree in terms of list + structure.
balanced,i.e., that the + left and the right subtree of every tree have approximately the same + number of elements, so that each subtree contains about half the + elements of its parent. But how can we be certain that the trees we + construct will be balanced? Even if we start with a balanced tree, + adding elements with +
randomlythe tree + will tend to be balanced on the average. But this is not a guarantee. For + example, if we start with an empty set and adjoin the numbers 1 through 7 + in sequence we end up with the highly unbalanced tree shown in + figure
randomly accessedare typically implemented by a tree-based + method, such as the binary-tree representation discussed previously. + In designing such a system the methodology of data abstraction + can be a great help. The designer can create an initial implementation + using a simple, straightforward representation such as unordered lists. + This will be unsuitable for the eventual system, but it can be useful in + providing a
quick and dirtydata base with which to test the + rest of the system. Later on, the data representation can be modified to + be more sophisticated. If the data base is accessed in terms of abstract + selectors and constructors, this change in representation will not require + any changes to the rest of the system. +
A | +000 | +
+ |
+ C | +010 | +
+ |
+ E | +100 | +
+ |
+ G | +110 | +
B | +001 | ++ | D | +011 | ++ | F | +101 | ++ | H | +111 | +
+BACADAEAFABBAAAGAH |
+001000010000011000100000101000001001000000000110000111 |
A | +0 | +
+ |
+ C | +1010 | +
+ |
+ E | +1100 | +
+ |
+ G | +1110 | +
B | +100 | ++ | D | +1011 | ++ | F | +1101 | ++ | H | +1111 | +
+100010100101101100011010100100000111001111 + |
alphabetof symbols and their relative frequencies, + how do we construct the
bestcode? (In other words, which + tree will encode messages with the fewest bits?) Huffman gave an algorithm + for doing this and showed that the resulting code is indeed the best + variable-length code for messages where the relative frequency of the + symbols matches the frequencies with which the code was constructed. +
+ Initial leaves + | +
+ |
+
+ Merge + | +
+ |
+
+ Merge + | +
+ |
+
+ Merge + | +
+ |
+
+ Merge + | +
+ |
+
+ Merge + | +
+ |
+
+ Merge + | +
+ |
+
+ Final merge + | +
+ |
+
downthe tree, choosing a left or + a right branch according to whether the next bit in the list is a zero or a + one. (This is done with the +
symbolsof an +
alphabetneed not be individual letters.) +
+ A + | ++ 2 + | +
+ |
+ + NA + | ++ 16 + | +
+ BOOM + | ++ 1 + | +
+ |
+ + SHA + | +
+ |
+
+ GET + | ++ 2 + | +
+ |
+ + YIP + | +
+ |
+
+ JOB + | ++ 2 + | +
+ |
+ + WAH + | +
+ |
+
Get a job | +
Sha na na na na na na na na | +
Get a job | +
Sha na na na na na na na na | +
Wah yip yip yip yip yip yip yip yip yip | +
Sha boom | +
复数数据对象概念的同时,设计独立的矩形和极坐标表示形式。 + 我们将通过定义针对复数的算术 +
数字,并且在需要新的数字类型时可以轻松扩展。在
实数轴和
虚数轴。(参见图。)从这个角度看,复数
矩形形式,或者表示为一对(模,角)的
极坐标形式。我们该选择哪一种呢? +
最少承诺原则。的一种应用。在第
操作+
类型标签所表示的数据为代数运算符号 +
智能操作来进行基于数据类型的分派,而使用
智能数据对象来进行基于操作名称的分派。我们可以通过这样的安排,使得一个数据对象,例如矩形数,被表示为 +
消息的形式接收所请求的操作名称。 我们已经在第
install库中。我们也可以为新操作配备
install库。 +
数字的人的角度来看,只有一个 +
问题在于,复数选择器从未为 +++ + 数定义,而只为 ++ 复数 + "复数" + + 和 ++ 极坐标 + "polar" + + 数定义。要使其工作,你只需在 ++ 直角坐标 + "rectangular" +复数 + 包中添加以下内容:
图,并自动生成那些可以从显式给出的强制转换 +
全局的结构。例如,假设我们正在构建一个通用算术系统,以处理整数、有理数、实数和复数。在这样的系统中,将整数视为特殊类型的有理数是非常自然的,而有理数又是特殊类型的实数,实数又是特殊类型的复数。实际上,我们拥有的是所谓的类型的层次结构,其中,例如,整数是有理数的
继承了其超类型所定义的所有操作。例如,如果我们没有为整数提供一个专门的 +
兼容的方式实现这一点,并且不会在向塔中添加新级别时引发问题。 + +
简化其的方法。设计一个
下推。例如,对复数进行投影将涉及丢弃其虚部。接着,当我们对一个数进行
简化结果。 + +
yes, if we are considering a polynomial purely as a + mathematical function, but no, if we are considering a polynomial to be a + syntactic form.The second polynomial is algebraically equivalent + to a polynomial in
polynomialwill be a + particular syntactic form, not its underlying mathematical meaning. +
data-directed recursionin which, for example, a call to +
numberto a + polynomial by regarding it as a polynomial of degree zero whose coefficient + is the number. This is necessary if we are going to perform operations + such as +
densityof the polynomials we intend + to manipulate. A polynomial is said to be +
recursive data abstraction,in that parts of a polynomial may + themselves be polynomials. Our generic operations and our + data-directed programming style can handle this complication without + much trouble. +
abovethe other in any natural way, yet it is + often necessary to add together elements from each set. There are several + ways to do this. One possibility is to convert one polynomial to the type + of the other by expanding and rearranging terms so that both polynomials + have the same principal variable. One can impose a towerlike structure on + this by ordering the variables and thus always converting any polynomial + to a +
canonical formwith the highest-priority variable + dominant and the lower-priority variables buried in the coefficients. + This strategy works fairly well, except that the conversion may expand + a polynomial unnecessarily, making it hard to read and perhaps less + efficient to work with. The tower strategy is certainly not natural + for this domain or for any domain where the user can invent new types + dynamically using old types in various combining forms, such as + trigonometric functions, power series, and integrals. +
fractionswhose numerator and + denominator are polynomials, such as +
cross multiplicationwould have produced a + fourth-degree polynomial over a fifth-degree polynomial.) +
greatest common divisormakes sense for polynomials. In + fact, we can compute the GCD of two polynomials using essentially the + same Euclid
measure
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
自然地分成可以独立开发和维护的多个部分。 +
世界观产生的两种突出的组织策略。第一种组织策略集中于
具有状态。例如,一个银行账户具有状态,因为对于
我可以提现这个问题的答案取决于存款和取款交易的历史。我们可以通过一个或多个100吗?
need to know.
need to + know.
withdrawal processors.+ The
bank-account objectwith a specified initial + balance: +
messageas input and returns one of the two local +
随机选择”的含义是什么。 + 我们想要的可能是连续调用 +
相同的概念。 +
位置。 +
位置。 +
提款处理器+ 来自章节
位置。 +
withdraw对象时会发生什么 +
粘合剂。我们在本节开始时定义了序对的基本修改器,以便序对可以作为构建可变数据对象的构建块。这些修改器大大增强了序对的表示能力,使我们能够构建除节中处理的序列和树之外的数据结构。我们还展示了一些模拟的例子,其中复杂系统被建模为具有局部状态的对象集合。 +
垃圾。我们将在第
临时+
同一性和
变化的理论问题。这些问题在实践中出现, + 当单个对在不同的数据对象之间被共享时。例如,考虑由下列构成的结构 +
相同的列表: +
相同的结构, + 应用 +
sameness和
change的根本问题。我们在该节中提到,允许语言中发生变更要求复合对象必须具有一种与其组成部分不同的
identity。在 +
identity正是通过 +
itself是存储在计算机中某一特定内存位置集合中的信息,从而“解决了问题”。这对于简单的 +
sameness问题的通用方法。
它很简单,他推理道。
在任何结构中,对的数量等于在 +因此本·比特迪德尔编写了如下 ++ + 中的数量,加上在 ++ car + head + + 中的数量,再加上一个以计算当前这一对。+ cdr + tail
+ 操作 + | ++ 结果队列 + | +
+ |
+ + | +
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
It他抱怨道。 +s all wrong!
The interpreter+ Eva Lu Ator 认为 Ben 对正在发生的事情理解有误。 +s response shows that the last item is inserted + into the queue twice. And when I delete both items, the second + b is still there, so the queue isnt + empty, even though it s supposed to be.
It她解释道。 +s not that the + items are going into the queue twice,
It+ 解释 Eva Lu 所说的内容。具体来说,展示为什么 Ben 的示例会产生如此的打印结果。 + 定义一个 +s just that the standard + + + printer doesnLisp +JavaScript +t know how to make sense of the queue representation. + If you want to see the queue printed correctly, you ll have to define + your own print + + + for queues.procedure +function +
双端队列) 是一种序列,在这种序列中可以在 +
记录
本身的对象;也就是说,指向表的指针实际上就是指向该对的指针。这个骨干对始终作为表的起始,如果不这样安排, +
表对象提供用于操作内部表的 +
相等性。 +
事件) 会触发后续在稍后发生的事件,而这些事件又触发更多事件,依此类推。 +
保存信号。功能块将由 +
过程
函数
数据的角色。例如,如果我们写下 +
+ 与过程 函数
数据之间没有本质区别,我们可以选择合适的语法糖以允许我们以任意风格编程。 +
探针,展示了仿真器的运行。探针告知导线,每当其信号发生变化时,应打印出新的信号值,同时显示当前时间以及一个用于标识 +
one-armed+if expression
one-armed conditional statement+
holdsa + value that may participate in one or more constraints. For example, we know + that the relationship between Fahrenheit and Celsius temperatures is +
syntax interfaces(see + footnote
constraint+ versions of the arithmetic operations. For example, +
imperative style,+ using +
过程,但在本节中,我们使用术语
线程来强调它们对共享内存的访问。
Time +time + is a device that was invented to keep + everything from happening at once.purpose of
cached) among the different + processors to increase the speed of memory access.
correctresult produced by a concurrent + program, because we require only that the result be the same as for + some sequential order. For example, suppose that Peter and + Paul
Peter: | +|
Paul: | +|
Mary: | +
Peter: | +|
Paul: | +|
Mary: | +
101: | +|
121: | +|
110: | +|
+ | +
+ accesses the value of
+ |
+
11: | +|
100: | +
101: | +|
121: | +|
110: | +|
+ |
+ accesses the value of
+ |
+
100: | +
mutexis an abbreviation for +
THEMultiprogramming System developed at the +
busy-waitingas above. Instead, the system + schedules another +
back outof the deadlocked state and try again. + Deadlock-recovery mechanisms are widely used in + data-base-management systems, a topic that is treated in detail in +
shared state.+
barriers) through which no +
the account balancewould be + undetermined, except right after synchronization. If Peter deposits money + in an account he holds jointly with Paul, when should we say that the + account balance has changed
correct? The only thing that might matter for correctness + is the behavior observed by Peter and Paul individually and the +
stateof the account immediately after synchronization. + Questions about the
realaccount balance or the order of + events between synchronizations may be irrelevant or + meaningless.
global clocksthat can be used to establish orderings on + events in distributed systems.
world linesof particles as a device for reasoning about + motion. We
promiseto evaluate
outrageousprime computation we saw above, reformulated + in terms of streams: +
demand-driven+ programming, whereby each stage in the stream process is activated + only enough to satisfy the next stage. What we have done is to +
all at oncewhen, in reality, the computation is + performed incrementally, as in traditional programming styles. +
promise+ to compute the rest if it is ever requested. + If we have a data item +
wrappedin a function of no arguments, +
outrageousprime computation we saw above, reformulated + in terms of streams: + +
demand-drivenprogramming, whereby each stage in the + stream process is activated only enough to satisfy the next stage. What + we have done is to +
all at oncewhen, in reality, the computation is + performed incrementally, as in traditional programming styles. +
sievesthat, until the 1970s, + were the + most powerful tools in existence for locating large primes. Since then, + however, these methods have been superseded by outgrowths of the +
Henderson diagramin +
un+cons er
un+pair er
generating+
timelessstream of values + rather than as a set of variables to be updated. Let
super-accelerationof the +
loopingmust range over an infinite set. +
less thananother. One way to do + this is to define a +
weighting function+
It was + Mr.The trick of using weighted pairs to + generate the Ramanujan numbers was shown to us by +Littlewood + (I believe) who remarked that every positive integer was one of his + friends.I remember once going to see him when he was lying ill + at Putney. I had ridden in taxi-cab No. 1729, and remarked that the number + seemed to me a rather dull one, and that I hoped it was not an unfavorable + omen.No,he replied,it is a very interesting number; + it is the smallest number expressible as the sum of two cubes in two + different ways.
signalsin signal-processing systems. + In fact, we can use streams to model signal-processing systems in a very + direct way, representing the values of a signal at successive time + intervals as consecutive elements of a stream. For instance, we can + implement an +
implicit styledefinition of the + stream of integers (section
+ Write a
+
hidden+
analog computer circuitthat solves the equation +
analog computer circuitthat solves the equation +
implicitdefinition of the + infinite stream of integers in + section
map a given +by a single higher-order ++ +procedure +function ++ + over all the elements in a sequence+ proc + fun
data typein the presence + of higher-order +
polymorphic data types
parametrically polymorphic data types
hiding,parts + of the state of a large system within local variables. Stream models can + provide an equivalent modularity without the use of assignment. As an + illustration, we can reimplement the +
randomnumbers. + Produce a stream formulation of this same generator that operates on an + input stream of requests to +
withdrawal processorthat + monitors the balance in a +
objectsin our computer. +
objectsper se, we have + already indicated that a bank account can be modeled as a process that + operates on a stream of transaction requests to produce a stream of + responses. Accordingly, we could model the fact that Peter and Paul have a + joint bank account by merging Peter
real + timeas perceived by Peter and Paul, in the sense that, if Peter and + Paul meet, they can agree that certain transactions were processed + before the meeting, and other transactions were processed after the + meeting.
merge+ is a +
correctorder + of events in concurrent processing of objects with state. Thus, in an + attempt to support the functional style, the need to merge inputs from + different agents reintroduces the same problems that the functional style + was meant to eliminate. +
objectsis much larger than the + state that they share. An example of a place where the object viewpoint + fails is +
+ The evaluator, which determines the meaning of ++ To appreciate this point is to change our images of ourselves as + programmers. We come to see ourselves as designers of languages, + rather than only users of languages designed by others. ++ expressions in a programming language, is just another program. + statements and
Lisp
possible futuresand then searching for appropriate time + lines. With our nondeterministic evaluator, keeping track of multiple values + and performing searches are handled automatically by the underlying + mechanism of the language. +
scanned outbefore the body of the block is + evaluated. + The body of the block is evaluated with respect to an environment + that extends the current + environment by a frame that binds each local name + to a special value, +
+++$\ll\ \mathit{predicate}\ \texttt{?}\ \mathit{consequent}\textit{-}\mathit{expression}\ \texttt{:}\ \mathit{alternative}\textit{-}\mathit{expression}\ \gg\ \ = $ + ++ ++list("conditional_expression", + $\ll\ $predicate$\ \gg$, + $\ll\ $consequent-expression$\ \gg$, + $\ll\ $alternative-expression$\ \gg$) + +
+++$\ll\ \textbf{if}\ \texttt{(} \mathit{predicate} \texttt{)}\ \mathit{consequent}\textit{-}\mathit{block}\ \textbf{else}\ \mathit{alternative}\textit{-}\mathit{block}\ \gg\ \ =$ + ++ ++list("conditional_statement", + $\ll\ $predicate$\ \gg$, + $\ll\ $consequent-block$\ \gg$, + $\ll\ $alternative-block$\ \gg$) + +
+++$\ll\ \texttt{(}\mathit{name}_1\texttt{, }\ldots\texttt{, } \mathit{name}_n \texttt{) =>}\ \mathit{block}\ \gg\ \ =$ + ++ ++list("lambda_expression", + list($\ll\ name_1\;\gg$, $\ldots$, $\ll\ name_n\;\gg$), + $\ll\ block\ \gg$) + +
+++$\ll\ \textbf{function}\ \mathit{name} \texttt{(}\mathit{name}_1\texttt{, }\ldots\texttt{, } \mathit{name}_n \texttt{)} \ \mathit{block}\ \gg\ \ =$ + ++ ++list("function_declaration", + $\ll\ $name$\ \gg$, + list($\ll\ $name$_1\;\gg$, $\ldots$, $\ll\ $name$_n\;\gg$), + $\ll\ $block$\ \gg$) + +
+++ $\ll\ \mathit{expression}_1\ \ \mathit{logical}\textit{-}\mathit{operation}\ \ \mathit{expression}_2\;\gg \ \ = $ + ++ ++list("logical_composition", + "$logical$-$operation$", + list($\ll\ $expression$_1\;\gg$, $\ll\ $expression$_2\;\gg$)) + +
Namedis a variant of +let
+++ $\ll\ \textbf{while} \ \texttt{(}\ \mathit{predicate}\ \texttt{)}\ \mathit{block}\ \gg \ \ =$ + ++ ++ $\ll\ $while (predicate) block$\ \gg$ = + list("while_loop", $\ll\ $predicate$\ \gg$, $\ll\ $block$\ \gg$) + +
staticallymeans that + we can make the distinction by inspecting the program + rather than by running it.) + All declarations are + non-value-producing, and all + expression statements and conditional statements are + value-producing. + The value of an expression statement is the value of the expression. + The value of a conditional statement is the value of the branch that + gets executed, or the value +
predicateexpression. JavaScript's notion of + truthiness and falsiness is captured by the following variants of +
Not a Number), +
truthyand
falsywere coined + by +
+ returns the value that is bound to the symbol
+
+ returns a new environment, consisting of a new frame in which the
+ symbols in the list
+ adds to the first frame in the environment
+
+ changes the binding of the variable
unbound + variable+
arraysin JavaScript.) + Thus, the
what can in principle be computed+ (ignoring practicalities of time and memory required) is independent of the + language or the computer, and instead reflects an underlying notion of +
effective + processcan be formulated as a program for such a machine. (This + argument is known as the +
effective processes.Turing went on + to make fundamental contributions to practical computer science as well. + For example, he invented the idea of +
halton +
accidentalreason: Since the definitions + of the internal procedures come first, no calls to these procedures + will be evaluated until all of them have been defined. Hence, +
management is not responsibleremark in + footnote
badly formedprograms. However, we will + see in section
scan outand eliminate all the internal definitions in + the body. The internally defined variables will be created with a +
Why can't + the evaluator take care of this chore, and ++hoisting of function declarations +function declaration + hoist all function + declarations to the beginning of the block in which they appear? Function declarations outside of blocks should be hoisted to the beginning of the program.hoisting of
pure +implementation of + recursion. (See +$\lambda$ -calculus
simultaneousscope rule for + internal definitions without constructing the extra frame. +
accidentalreason: Since the declarations + of the internal functions come first, no calls to these functions + will be evaluated until all of them have been declared. Hence, +
pure +implementation of + recursion. (See +$\lambda$ -calculus
To grab, especially a large document or + file for the purpose of using it either with or without the ownerSnarf down:s + permission.
To snarf, sometimes with the + connotation of absorbing, processing, or understanding.+ (These definitions were +
lazyterminology and the
normal-order+ terminology is somewhat fuzzy. Generally,
lazyrefers to the + mechanisms of particular evaluators, while
normal-order+ refers to the semantics of languages, independent of any particular + evaluation strategy. But this is not a hard-and-fast distinction, and the + two terminologies are often used interchangeably.
strictversus
non-strict+ terminology means essentially the same as +
applicative-orderversus
normal-order,except + that it refers to individual +
The normal-order + language +Hassle + Hassle has certain strict primitives. Other ++ + take their arguments by lazy evaluation.procedures +functions +
thinking + about) the expression could be done at compile time; thus, at run + time, the expression would already have been
thunkabout +
promiseto compute the +
lazy trees.
lazierlazy lists described in + this section. How can you take advantage of this extra laziness? +
listsobtained +
generate and testapplications. Consider the task of + starting with two lists of positive integers and finding a pair of + integers
pseudo-Lisp
pseudo-JavaScript
ambiguously.For example, + the expression +
fail: The computation aborts and no value is produced. + Using this idea, we can express the requirement that a particular predicate + expression
Automatically, but in a way + which, for some reason (typically because it is too complicated, or too ugly, + or perhaps even too trivial), the speaker doesn+t feel like + explaining.
+ The software company ++Gargle + Gargle is expanding, and Alyssa, Ben, Cy, Lem, and Louis + are moving into a row of five private offices in a + new building. Alyssa does not move into the last office. Ben does not + move into the first office. Cy takes neither the first nor the last office. + Lem moves into an office after Ben's. Louis's office is not next to + Cy's. Cy's office is not next to Ben's. Who moves into which office? + +
Liarspuzzle (adapted from +
+ Alyssa, Cy, Eva, Lem, and Louis meet for a business lunch at SoSoService. + Their meals arrive one after the other, a considerable time after they + placed their orders. To entertain Ben, who expects them back at the office + for a meeting, they decide to each make one true statement and one false + statement about their orders: +++
+ What was the real order in which the five diners received their meals? + +- + Alyssa: +
+Lem's meal arrived second. Mine arrived third.+- + Cy: +
+Mine arrived first. Eva's arrived second.+- + Eva: +
+Mine arrived third, and poor Cy's arrived last.+- + Lem: +
+Mine arrived second. Louis's arrived fourth.+- + Louis: +
+Mine arrived fourth. Alyssa's meal arrived first.+
+ Alyssa, Ben, Cy, Eva, and Louis each pick a different chapter of SICP JS + and solve all the exercises in that chapter. + Louis solves the exercises in the+ Try to write the program so that it runs efficiently (see + exerciseFunctionschapter, + Alyssa the ones in theDatachapter, and + Cy the ones in theStatechapter. + They decide to check each other's work, and + Alyssa volunteers to check the exercises in theMetachapter. + The exercises in theRegister Machineschapter are solved by Ben + and checked by Louis. + The person who checks the exercises in theFunctionschapter + solves the exercises that are checked by Eva. + Who checks the exercises in theDatachapter? +
Metachapter. + +
eight-queens puzzleof placing queens on a chessboard so that + no two attack each other. Write a nondeterministic program to solve this + puzzle. +
The cat eats.To accomplish + such an analysis, we must be able to identify the parts of speech of + individual words. We could start with some lists that classify various + words:
The cat eatsis parsed as follows: +
for the cat) to be + a preposition followed by a noun phrase: +
a cat in the class.What + we used to call a noun phrase, we
The professor lectures to the student with the cat,+ it may be that the professor is lecturing with the cat, or that the student + has the cat. Our nondeterministic program finds both possibilities: +
The professor lectures to the student in the class + with the cat.Give the five parses and explain the differences in + shades of meaning among them. +
input sentenceand instead always + succeeds and generates an appropriate word, we can use the programs we had + built for parsing to do generation instead. Implement Alyssa
falls intoone of these recursions + and gets stuck. See exercise
applicationas + a nondeterministic choice point.
succeeds.+
failureindicates a program + bug
*1*below) + that saves the old value of the variable before assigning the new value to + the variable and proceeding from the assignment. The failure continuation + that is passed along with the value of the assignment (marked with the + comment
*2*below) restores the old value of the variable + before continuing the failure. That is, a successful assignment provides a + failure continuation that will intercept a subsequent failure; whatever + failure would otherwise have called
failurealternative branch in order to search for additional + successful evaluations. +
punthat an expression that describes the value of a + function may also be interpreted as a means of computing that value. + Because of this, most programming languages are strongly biased toward + unidirectional computations (computations with well-defined inputs and + outputs). There are, however, radically different programming languages + that relax this bias. We saw one such example in + section
how toknowledge than would be the case with an ordinary + arithmetic computation. This does not mean, however, that the user is + released altogether from the responsibility of providing imperative + knowledge. There are many constraint networks that implement the same set + of constraints, and the user must choose from the set of mathematically + equivalent networks a suitable network to specify a particular computation. +
what is+ fact can be used to solve a number of different problems that would have + different
how tocomponents. As an example, consider the +
what is(rules) vs.
how to(
+ Find the+ But the same two rules are also sufficient for answering the following + sorts of questions, which the +append of ++ + and ++ (a b) + list("a", "b") ++ ++ (c d) .list("c", "d") . +
+ Find a list+y + that +append s with ++ + to produce ++ +(a b) ++ +list("a", "b") ++ ++ (a b c d) .+ ++ list("a", "b", "c", "d") .
+ Find all+ In a +x andy + thatappend to form ++ ++ (a b c d) .+ +list("a", "b", "c", "d") . +
procedure
function
what is(rules) vs.
how to(
How toknowledge is provided automatically by the + interpreter to allow this single pair of rules to be used to answer all + three types of questions about +
what isinformation gives no clue +
how tocompute an answer. For example, consider the problem + of computing the
how tomethods can lead them into spurious infinite loops or + other undesirable behavior. Logic programming is an active field of research + in computer science.
evaluatepart that classifies + expressions according to type and an
applypart that + implements the language
predicates, as in the original book. We did not resist the + temptation to syntactically introduce
predicate symbols, + for the following reasons: +
argumentsare lists or primitive values such as strings + and numbers. The first symbols do not need to be declared, as do constants + or variables in JavaScript; their scope is global. +
predicate symbolsinstead of +
kind of information+ because the term +
predicateis already used, also in this section, + for JavaScript expressions and functions that return boolean values. +
anythingthat can be the second item in the matching + list is specified by a +
anything.+
anythingthat can be the first item in the matching + assertion is specified by a +
anything.+
anythingmust appear in each + position. This is why variables have names. For example, +
dotted-tail notationin the + JavaScript edition: We simply use +
wheelin an + organization if he supervises someone who is in turn a supervisor: +
big shotin a + division if the person works in the division but does not have a supervisor + who works in the division. + +
: +x and +y append to + formz
+ Which list, when+append ed to +(a b) , yields +(a b c d) ?
Which list, when+append ed to +list("a", "b") , yields +list("a", "b", "c", "d") ? +
If S is the son of F, and + F is the son of G, then S is the grandson of + Gand
If W is the wife of M, and + S is the son of W, then S is the son of + M(which was supposedly more true in biblical times than + today) that will enable the query system to find the grandson of Cain; the + sons of Lamech; the grandsons of Methushael. + (See +
Find all people who can do the job of a computer + programmer trainee), we first find all entries that match the + pattern +
patternand the
datummay contain variables. +
whatis to be computed, and
howthis + should be computed. This is accomplished by selecting a subset of the + statements of mathematical logic that is powerful enough to be able to + describe anything one might want to compute, yet weak enough to have a + controllable procedural interpretation. The intention here is that, + on the one hand, a program specified in a logic programming language + should be an effective program that can be carried out by a computer. + Control (
howto compute) is effected by using the order of + evaluation of the language. We should be able to arrange the order of + clauses and the order of subgoals within each clause so that the + computation is done in an order deemed to be effective and efficient. + At the same time, we should be able to view the result of the + computation (
whatto compute) as a simple consequence of the + laws of logic. +
inferenceaccomplished by a logic program by asserting that + the same result could be obtained by working entirely within + mathematical logic.
inferenceaccomplished + by a logic program, we assume that the computation terminates. + Unfortunately, even this qualified statement is false for our + implementation of the query language (and also false for programs in + Prolog and most other current logic programming languages) because of + our use of
To showfor some suitably + chosen function$P(x)$ is true, show that +$P(f(x))$ is true,
notto + mean that$P$
notmeans that +$P$
Negation as Failureby +
Oh, no, my simple accumulation + scheme won+ + What has Ben just realized? Outline a method he can use to salvage the + situation. + +t work!
greatsto a grandson relationship. This should enable the + system to deduce that Irad is the great-grandson of Adam, or that Jabal + and Jubal are the great-great-great-great-great-grandsons of Adam. + (Hint: Represent the fact about Irad, for example, as +
greatto a grandson relationship. This should enable the + system to deduce that Irad is the great-grandson of Adam, or that Jabal + and Jubal are the great-great-great-great-great-grandsons of Adam. +
HiLog: A foundation for higher-order logic + programming. Journal of Logic Programming. 15 (3): 187–230. +
***below) to handle + the case where the object on the right side of the match is a variable. +
***in the program below. In + the first case, if the variable we are trying to match is not bound, but + the value we are trying to match it with is itself a (different) variable, + it is necessary to check to see if the value is bound, and if so, to match + its value. If both parties to the match are unbound, we may bind either + to the other. +
argumentlist of +
wronganswers if + these filtering operations are applied to frames in which variables + are unbound. Devise a way to fix this shortcoming. One idea is to + perform the filtering in a
delayedmanner by appending to + the frame a
promiseto filter that is fulfilled only when + enough variables have been bound to make the operation possible. We could + wait to perform filtering until all other operations have been performed. + However, for efficiency
If I supposed that) as a method of problem + solving? (This problem is open-ended.) + +$P$ + were true, then I would be able to deduce$A$ + and$B$ .
machine-language+ programs for traditional computers. However, instead of focusing on + the machine language of any particular computer, we will examine + several +
temporaryregister, which we call +
flowinto the designated register. + The label next to each button is the name we will use to refer to the + button. The names are arbitrary, and can be chosen to have mnemonic value + (for example,
Push button +and separately saying (in the + data paths)t<-r
Buttonandt<-r assigns the + value of therem operation to register +t
The ++ we will say (in the controller)rem operations inputs are the contents + of registers + register-machine language +(in register machine) +register-machine language +(in register machine) +register-machine language +(in register machine) +a andb ,
Push the button that assigns to + register+ Similarly, instead of saying (in the controller)t the value of the +rem operation on the contents of registers +a andb .
Perform the +and separately saying (in the + data paths)= test
Thewe will say= test operates on the + contents of registerb and the + constant 0,
Perform the +We will omit the data-path description, leaving only + the controller sequence. Thus, the GCD machine is described as follows: + + += test on the +register-machine language +(in register machine) + contents of registerb and the + constant 0.
primitive+ operations that are actually very complex. For example, in + sections
primitivesby simpler primitive operations. +
last in, first outdata + structure, to save register values. We can extend the register-machine + language to include a stack by adding two kinds of instructions: Values are + placed + on the stack using a +
levelof + the factorial computation will use the same +
program counter). The internal +
continuation.Recall that we + also used continuations to implement the backtracking control + structure in the
operation expression
meterthat measures the number of stack operations used in a + computation. To do this, we modify our simulated stack to keep track + of the number of times registers are saved on the stack and the + maximum depth reached by the stack, and add a message to the stack
box-and-pointerstructure of +
arrays.We use the term vector in + this book, as it is the more common terminology. + The vector functions above are easily implemented using + JavaScript's primitive array support.
pointerto include information on data type.
tagged dataidea we introduced in chapter
pair+ data type and an index into the memory vectors) from pointers to other + kinds of data (which consist of some other data type and whatever is + being used to represent data of that type). Two data objects are +
digitis a + number between 0 and the largest number that can be stored in a single + pointer.
samesymbol by +
samestring by +
primitivelist operation of a register machine with one or + more primitive vector operations. We will use two registers, +
working memoryand
free memory.When +
real-timeversion of the method, + which does not require the computation to stop during garbage collection. + Baker
swept upas garbage and made available for reuse. A full + discussion of the mark-sweep method can be found in +
relocated+
pairthat doesn
explicit + controlin this evaluator allows a return statement to jump directly to + the continuation of the current function application without resuming the + sequence evaluation. Thus sequence evaluation does not need to be concerned + with returns, or even be aware of the existence of return statements in the + language. Because a return statement jumps out of the sequence-evaluation code, + the restores of saved registers at
cheatand assume that the syntax + transformers such as
cheatby assuming that the syntax transformer +
unknown procedure type error
unknown function typeerror
+++ \begin{center} + \smallskip + \begin{tabular}{l|l|l} + & Maximum depth & Number of pushes \\ \hline + \rule{0pt}{7mm} Recursive factorial & & \\ \hline + \rule{0pt}{7mm} Iterative factorial & & \\ \hline + \end{tabular} + \smallskip + \end{center} + +
overheadconstant +
dumps + core,and in +
kernel panicor a
blue + screen of deathor even a reboot. Automatic rebooting is an approach + typically used on phones and tablets. Most modern operating systems do a + decent job of preventing user programs from causing an entire machine to + crash. +
in lineinstead + of using a general
dead codeafter the return statement that can + never be executed. + Removing the
code following a return statement in a sequence
return+ directly to the place specified by the caller
in lineto be executed as part of the combined + sequence, its register use has no impact on the register use of the sequence + in which it is embedded. We thus ignore the +
real
compoundto mean interpreted (as opposed to + compiled).
Worm
Worm+ that paralyzed the Internet in 1988 exploited the +
primitivein our discussion of + the evaluator and compiler. One strategy for minimizing work here is + to write as many of these operations as possible in +
register-machine + operations.+ +
universal: can it + conveniently fulfill the roles of those 10 more specialized data + structures? +
yes; it is only slightly tricky to construct a + function that accepts (1) a data structure that serves as a + description of some other function, and (2) a list of arguments, + and behaves exactly as that other function would when applied to + the given arguments. And it is only slightly tricky to design a + data structure capable of describing any computation + whatsoever. One such data structure (the tagged-list + representation of expressions and statements, paired with + environments that associate names with values) and one such + universal function (
+ ((S ((S (K S)) ((S ((S (K S)) ((S (K K)) (K +)))) ((S (K K)) I)))) (K I)) ++ even though there is a direct structural correspondence, easily + expressed in five lines of Lisp code. +
Growing a Language,I commented + that a good programmer
does not just write programs. A good + programmer builds a working vocabulary.As we design and + define more and more parts of our programs, we give names to + those parts, and the result is that we have a richer language in +
This list of two + things I expect to be a personal name and a surname, but that + list of two things I expect to be the real and imaginary parts + of a complex number, and that other list of two things I will + regard as the numerator and denominator of a fraction.+ In other words, I draw distinctions
object-orientedapproach, and many + languages, including JavaScript, support specialized data structures + such as objects and strings and heaps and maps with a variety of + built-in mechanisms and libraries. But in doing so, many languages + abandoned support for more general, universal notions. Java, for + example, originally did not support first-class functions, and has + incorporated them only relatively recently, greatly increasing its + expressive power. +
programis focused on the creation, execution, and study of +programs written in a dialect of Lisp for execution on a digital +computer. Using Lisp we restrict or limit not what we may program, +but only the notation for our program descriptions. +
machineprograms are +themselves abstract models which we program. Their study and creation +give a great deal of insight into the organizational programs +associated with programming arbitrary models. Of course the computer +itself can be so modeled. Think of it: the behavior of the smallest +physical switching element is modeled by quantum mechanics described +by differential equations whose detailed behavior is captured by +numerical approximations represented in computer programs executing on +computers composed of
Toward what end, toward +what end?
primitivein the book. +
Why Programming Is a Good + Medium for Expressing Poorly-Understood and Sloppily-Formulated + Ideas
The Structure and Interpretation of Computer Programsis the + entry-level subject in computer science at the Massachusetts Institute + of Technology. It is required of all students at MIT who major + in electrical engineering or in computer science, as one-fourth of the +
common core curriculum,which also includes two subjects on + circuits and linear systems and a subject on the design of digital + systems. We have been involved in the development of this subject + since 1978, and we have taught this material in its present form since + the fall of 1980 to between 600 and 700 students each year. Most of + these students have had little or no prior formal training in + computation, although many have played with computers a bit and a few + have had extensive programming or hardware-design experience. +
mix and matchway. + We control complexity by establishing new languages for describing a + design, each of which emphasizes particular aspects of the design and + deemphasizes others. +
computer scienceis not a science and that its significance has + little to do with computers. The computer revolution is a revolution + in the way we think and in the way we express what we think. The + essence of this change is the emergence of what might best be called + procedural epistemology
what is.Computation provides a framework for dealing precisely + with notions of
how to.+
Contributors.+ Since 2020, the students of the NUS course CS4215, Programming + Language Implementation, contributed several programming language + implementations that are used in SICP JS: The concurrent version + of Source used in section 3.4 was developed by Zhengqun Koo and + Jonathan Chan; the lazy implementation used in section 4.2 was developed + by Jellouli Ahmed, Ian Kendall Duncan, Cruz Jomari Evangelista, and + Alden Tan; the nondeterministic implementation used in section + 4.3 was developed by Arsalan Cheema and Anubhav; and Daryl Tan + helped integrate these implementations into the Academy. +
6.231,a +wonderful subject on programming linguistics and the lambda calculus +taught at MIT in the late 1960s by Jack Wozencraft and Arthur Evans, +Jr. +
unauthorizedtranslation. +
THE+ multiprogramming system. Communications of the ACM + 11(5):341
expensive procedure + callmyth. In Proceedings of the National Conference of the + ACM, pp. 153