Chapter 2, Building Abstractions with Data
Section - 2.1 - Introduction to Data Abstraction
Exercise 2.10
1
2
3
4
5
6
7
8
9
10
11
12
(define (div-interval x y)
(if (and (<= (lower-bound y) 0) (>= (upper-bound y) 0))
(error "Error: interval span contains 0 :" y)
(mul-interval
x
(make-interval
(/ 1. (upper-bound y))
(/ 1. (lower-bound y))
)
)
)
)
Output:
1
2
3
4
> (define I1 (make-interval 1 5))
> (define I2 (make-interval -5 2))
> (div-interval I1 I2)
. . Error: interval span contains 0 : {-5 . 2}