sicp 2.12

Exercise 2.12.  Define a constructor make-center-percent that takes a center and a percentage tolerance and produces the desired interval. You must also define a selector percent that produces the percentage tolerance for a given interval. The center selector is the same as the one shown above.

 

 

 

(define (make-center-percent center percent)
  (make-center-width center (* center percent)))

(define (center z)
  (* 0.5 (+ (lower-bound z) (upper-bound z))))

(define (percent z)
  (/ (* 0.5 (- (upper-bound z) (lower-bound z))) (center z)))

你可能感兴趣的:(SICP)