灯下 登录
计算机科学 / SICP / 4.1.2 Representing Expressions

Exercise 4.9 · 习题

Exercise 4.9: Many languages support a variety of

iteration constructs, such as do, for, while, and

until. In Scheme, iterative processes can be expressed in terms of

ordinary procedure calls, so special iteration constructs provide no essential

gain in computational power. On the other hand, such constructs are often

convenient. Design some iteration constructs, give examples of their use, and

show how to implement them as derived expressions.

练习 4.9:许多语言支持多种迭代构造,例如 do、for、while 和 until。在 Scheme 中,迭代型计算过程可以用普通的过程调用来表达,因此特殊迭代构造在计算能力上并不提供本质上的增益。另一方面,此类构造往往很便利。请设计若干迭代构造,给出其使用示例,并说明如何将它们实现为派生表达式。