Skip to content

Instantly share code, notes, and snippets.

@tetsu-miyagawa
Created July 2, 2015 20:47
Show Gist options
  • Save tetsu-miyagawa/c9f76c64ea0c58a8d2ce to your computer and use it in GitHub Desktop.
Save tetsu-miyagawa/c9f76c64ea0c58a8d2ce to your computer and use it in GitHub Desktop.
SICP Section 1.1.8-2
(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