Smatchcube's website 🌍


Exercise 1.20

Normal-order evalutation:

The second argument b must be evaluated each time the gcd procedure is called in order to check if b is equal to zero. The first argument a is only evaluated if b is zero.

On this last line the evaluation of b gives the number zero so the final result is the evaluation of a, that is:

We can count 18 calls of the remainder procedure with normal-order evaluation.

Applicative-order evaluation:

There are only 4 calls to the remainder procedure using applicative-order evaluation.