; Alyssa P. Hacker doesn't see why if needs to be provided as a special form. "Why can't I just define it as an ordinary procedure in terms of cond?" she asks.
(define (new-if predicate then-clause else-clause)
(cond (predicate then-clause)
(else else-clause)))
(define (square x) (* x x))
(define (average x y) (/ (+ x y) 2))
(define (improve guess x) (average guess (/ x guess)))
(define epsilon 0.001)
(define (good-enough? guess x)
(< (abs (- (square guess) x)) epsilon))
(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))
; The problem with new-if is loops written with it do not terminate no matter what the termination condition evaluates to. Both the loop end and next iteration clauses always execute and because the next iteration cause triggers executes both the loop end and next iteration clauses too, the execution gets stuck in an infinite loop.