Created
December 8, 2014 09:15
-
-
Save cohalz/f87bdd21d47f538405ef to your computer and use it in GitHub Desktop.
This file contains hidden or 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 (improve guess x) | |
| (average guess (/ x guess))) | |
| (define (average x y) | |
| (/ (+ x y) 2)) | |
| (define (square x) (* x x)) | |
| (define (good-enough? guess iguess) | |
| (= (/ guess iguess) 1)) | |
| (define (sqrt-iter guess x) | |
| (if (good-enough? guess (improve guess x)) | |
| guess | |
| (sqrt-iter (improve guess x) x))) | |
| (define (sqrt x) | |
| (sqrt-iter 1.0 x)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment