Welcome to the CHICKEN Scheme pasting service

square-root logical problem pasted by int0X80 on Thu Jan 24 08:29:17 2013

(define (square-root x)
        (define (avg a b)
                (/ (+ a b) 2))

        (define (abs a)
                (if (< a 0)
                       (- x)
                       x))
        
        (define (improve-guess guess)
                (avg guess (/ x guess)))

        (define (isgood-guess? guess)
               ( < (abs (- (square guess) x)) .001))

        (define (try guess)
                (if (isgood-guess? guess)
                       guess
                      (try (improve-guess guess))))
	(try 1)
	
)

globalized added by certainty on Thu Jan 24 08:33:45 2013

(define (square x) (* x x))

(define (avg a b)
  (/ (+ a b) 2))

(define (improve-guess guess x)
  (avg guess (/ x guess)))

(define (isgood-guess? guess x)
  ( < (abs (- (square guess) x)) .001))

(define (try guess x)
  (if (isgood-guess? guess x)
      guess
      (try (improve-guess guess x) x)))

(define (square-root x)
        (try 1))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
What's the procedure that returns the cdr of a cdr?
Visually impaired? Let me spell it for you (wav file) download WAV