Skip to content

Instantly share code, notes, and snippets.

@tetsu-miyagawa
Created July 2, 2015 20:44
Show Gist options
  • Save tetsu-miyagawa/bc05d9adce89b916fa7d to your computer and use it in GitHub Desktop.
Save tetsu-miyagawa/bc05d9adce89b916fa7d to your computer and use it in GitHub Desktop.
SICP Section 1.1.8
(define (square-root x)
(define (good-enough? guess x)
(< (abs (- (square guess) x)) 0.001))
(define (improve guess x)
(average guess (/ x guess)))
(define (sqrt-iter guess x)
(if (good-enough? guess x)
guess
(sqrt-iter (improve guess x) x)))
(sqrt-iter 1.0 x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment