Solution to SICP Exercise 1.5

Structure and Interpretation of Computer Programs

Solution to Exercise 1.5:

With applicative-order evaluation, the expression that Ben entered for evaluation will fail to terminate. The reason for this has to do with expression (p) evaluating to itself. When evaluating with applicative order, every combination within an expression is evaluated before the expression itself. The (p) combination never finishes evaluating because it keeps evaluating to itself.

With normal-order evaluation, the expression will be evaluated to 0. The reason is that the (p) combination is passed to test unevaluated. According to normal-order evaluation rules, it isn’t evaluated by the interpreter until its value is needed. The condition of the if expression in test is satisfied (because the expression (= 0 0) evaluates to #t, so the test procedure evaluates to 0. There is never any need to evaluate (p).

%d bloggers like this: