A variable that is defined in a let or function definition can be seen and used by all of the code inside that definition. This is called lexical scoping.
It is possible to have defines inside a function to define sub-functions that can only be used within that function. This can make the code clearer and reduce the number of parameters that must be passed:
(define (mysqrt x) (let ((epsilon 1.0e-8))
(define (mysqrtb estimate)
(define (new-estimate) (/ (+ estimate (/ x estimate)) 2))
(if (good-enough x (square estimate) epsilon) estimate (mysqrtb (new-estimate)) ) )
(mysqrtb 1.0) ) ) ; the code of mysqrt
Contents    Page-10    Prev    Next    Page+10    Index