灯下 登录
计算机科学 / SICP / 4.2.3 Streams as Lazy Lists

Exercise 4.33 · 习题

Exercise 4.33: Ben Bitdiddle tests the lazy list
implementation given above by evaluating the expression

(car '(a b c))

To his surprise, this produces an error. After some thought, he realizes that

the “lists” obtained by reading in quoted expressions are different from the

lists manipulated by the new definitions of cons, car, and

cdr. Modify the evaluator’s treatment of quoted expressions so that

quoted lists typed at the driver loop will produce true lazy lists.

练习 4.33:Ben Bitdiddle 通过对以下表达式求值来测试上面给出的惰性表实现:

(car '(a b c))

令他惊讶的是,这产生了一个错误。经过思考,他意识到,通过读入带引号表达式所得到的"表"与由新定义的 cons、car 和 cdr 操作的表是不同的。请修改求值器对带引号表达式的处理方式,使得在驱动循环中输入的带引号表能产生真正的惰性表。

Racket #lang sicp
(car '(a b c))