灯下 登录
计算机科学 / SICP / 1.2.5 Greatest Common Divisors

Exercise 1.20 · 习题

Exercise 1.20: The process that a procedure

generates is of course dependent on the rules used by the interpreter. As an

example, consider the iterative gcd procedure given above. Suppose we

were to interpret this procedure using normal-order evaluation, as discussed in

1.1.5. (The normal-order-evaluation rule for if is

described in Exercise 1.5.) Using the substitution method (for normal

order), illustrate the process generated in evaluating (gcd 206 40) and

indicate the remainder operations that are actually performed. How many

remainder operations are actually performed in the normal-order

evaluation of (gcd 206 40)? In the applicative-order evaluation?

练习 1.20:过程所产生的计算过程当然取决于解释器所使用的规则。以上面给出的迭代型 gcd 过程为例,假设我们用 1.1.5 节讨论的正则序求值来解释该过程。(if 的正则序求值规则在练习 1.5 中有所描述。)用代换模型(正则序)说明对 (gcd 206 40) 求值时产生的计算过程,并指出实际执行了哪些 remainder 运算。在正则序求值中,(gcd 206 40) 实际执行了多少次 remainder 运算?在应用序求值中呢?