Stephen on Software aka SOS

October 14, 2009

SICP Chapter 1.1 Exercises

Filed under: SICP — Tags: — sljm @ 11:20 am

Exercise 1.5

When using applicative order (1.1.3), the result is a never ending loop. Because when evaluating (test 0 (p)) the operator and the operands are evaluated that means the sub expression (p) is going to evaluate and since (p) is calling itself again, the result is a never ending loop

When using normal-order, since the operands are evaluate as needed, (p) is not going to be evaluated since the (if) statement will be true and so 0 is returned.

Blog at WordPress.com.