Exercise 2.8
> Using reasoning analogous to Alyssa's, describe how the difference of two intervals may be computed. Define a corresponding subtraction procedure, called sub-interval.
这道题目也比较简单,只要注意到区间之差的下界是被减区间的下界减去另一个区间的上界,上界是被减区间的上界减去另一个区间的下界即可。
; 计算 x-y 的结果
(define (sub-interval x y)(make-interval (- (lower-bound x) (upper-bound y))(- (upper-bound x) (lower-bound y))))(define r1 (make-interval 6.12 7.48))
(define r2 (make-interval 4.465 4.935))(display (sub-interval r1 r2)); 执行结果
[1.1850000000000005, 3.0150000000000006]