Created
July 2, 2015 20:47
-
-
Save tetsu-miyagawa/c9f76c64ea0c58a8d2ce to your computer and use it in GitHub Desktop.
SICP Section 1.1.8-2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (square-root x) | |
(define (good-enough? guess) | |
(< (abs (- (square guess) x)) 0.001)) | |
(define (improve guess) | |
(average guess (/ x guess))) | |
(define (sqrt-iter guess) | |
(if (good-enough? guess) | |
guess | |
(sqrt-iter (improve guess)))) | |
(sqrt-iter 1.0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment