Exercise 2.10 of SICP

Exercise 2.10: Ben Bitdiddle, an expert systems programmer, looks over Alyssa’s shoulder and comments that it is not clear what it means to divide by an interval that spans zero. Modify Alyssa’s code to check for this condition and to signal an error if it occurs.

If an interval I = [-2,2] spans 0, the inverse, I-1=[0.5,-0.5] which is wrong since the lower limit cannot be greater than the upper limit.

> (div-interval (make-interval 1 1) (make-interval -2 2))
*** ERROR IN (console)@76.1 — The dividing interval cannot span 0.

Leave a Reply