Код Ревью

Сравни свои решения

    #| BEGIN (Введите свое решение) |#
(define (compose f g)
  (lambda (x) (f (g x)))
)

(define (repeated f n)
  (if (= n 1)
    (lambda (x) (f x))
    (compose f (repeated f (- n 1)))
  )
)

(define tolerance 0.000001)

(define (fixed-point f first-guess)
  (define (close-enough? v1 v2)
   (< (abs (- v1 v2)) tolerance)
  )
  (define (try guess)
   (let ((next (f guess)))
    (if (close-enough? guess next)
     next
     (try next) 
    )
   )
  )
  (try first-guess)
)

(define (average-damp f)
  (lambda (x) (average x (f x))))

(define (average x y)
(/ (+ x y) 2))

(define (fast-expt b n)
   (cond ((= n 0) 1)
   ((even? n) (square (fast-expt b (/ n 2))))
   (else (* b (fast-expt b (- n 1)))))
)

(define (even? n)
  (= (remainder n 2) 0))

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

(define (nth-root n)
  (define (repeated-average-damp f)
    (if (even? n)
       (repeated (average-damp f) (/ n 2)) 
       (repeated (average-damp f) (/ (- n 1) 2))
     )
  )
 (lambda (x)
 (fixed-point 
    (repeated-average-damp (lambda (y) (/ x (fast-expt y (- n 1)))))
    1.0
  )
 )
)
#| END |#