SICP Exercise 2.10 requires us to deal with the problem of zero in interval division operations.
In the title of a professional program ape Ben Bitdiddle looked at the work of Alyssa after the question of zero, we pay attention to this person called Ben, will continue to appear this person, only if the person mentioned things are usually right, his role is a computer cattle man, It's just the kind of cow that the office can always see, and there's more bull in the back.
For the interval operation in addition to the zero problem, processing is also relatively simple, only need to infer whether the divisor is zero, the divisor is zero error. For an interval, the so-called zero is the interval across 0, and then a direct point is that the starting point is negative, the end point is a positive number.
Understanding the code will be very easy to write in the future:
(Define (div-interval x y) (If (< (* (Upper-bound y) (lower-bound y)) 0) (Error "Div 0:" y)) (Mul-interval x (Make-interval (/1.0 (Upper-bound y)) (/1.0 (Lower-bound y))))
OK, the problem is over.
SICP Exercises (2.10) Summary of solving problems: the problem of dividing zero in interval division