Title: (define (heron-sqrt <function>)
1(define (heron-sqrt ltfunctiongt) (method ((x
ltnumbergt)) Try some guess for sqrt(x)--we
always pick 1. (try 1 x))) (define (try
ltfunctiongt) (method ((guess ltnumbergt) (x
ltnumbergt)) If the guess is good enough (if
(good-enough? guess x) then stop and
return the old guess guess
otherwise, try an improved guess. (try
(improve guess x) x)))) (define (good-enough?
ltfunctiongt) (method ((guess ltnumbergt) (x
ltnumbergt)) (lt (abs (- (square guess) x))
0.0001))) (define (improve ltfunctiongt) (method
((guess ltnumbergt) (x ltnumbergt)) (/ ( guess
(/ x guess)) 2.0))) (define (square ltfunctiongt)
(method ((x ltnumbergt)) ( x x)))
2- The Substitution Model
- To evaluate a combination (other than a special
form) - evaluate the subexpressions of the combination
from left to right - apply the leftmost value (which must be a
function object) to the remaining values. - To apply a function to a list of values
- substitute each value for the corresponding
parameter in the body of the function - evaluate the body of the function.