Exercise 1.6
Imports: [[Chapter 1.1]] good-enough improve
(define (new-if predicate then-clause else-clause)
(cond (predicate then-clause)
(else else-clause)))
(new-if (= 2 3) 0 5) => 5
(new-if (= 1 1) 0 5) => 0
(define (sqrt-iter guess x)
(new-if (good-enough? guess x)
guess
(sqrt-iter (improve guess x) x)))
(define (sqrt x) (sqrt-iter 1.0 x))
(sqrt 9) =>...
When Alyssa attempts to use this to compute square roots, it will not work. The sqrt-iter procedure gets stuck in infinite recursion because the new-if combination always evaluates both clauses, so it always evaluate the recursive call.