1.5
Application order:
(test 0 (p))
(test 0 (p))
(test 0 (p))
...
Normal order:
(test 0 (p))
(if (= 0 0)
0
(p)))
0
1.6
new-if will cause the infinite loop:
(sqrt-iter 1.0 9)
(new-if (good-enough? 1.0 9)9(sqrt-iter (improve 1.0 9) 9))(new-if #f9(sqrt-iter 5.0 9))(new-if #f9(new-if (good-enough? 5.0 9)9(sqrt-iter (improve 5.0 9) 9))...
Since scheme is application-order, it will evaluate the subexpression at the beginning of the invocation. new-if function will evaluation the else-clause which is (sqrt-iter (improve 1.0 9) 9), but the sqrt-iter function will invoke new-if function again.

浙公网安备 33010602011771号