Exercise2-7 <---> Exercise2-9
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.
Ru: Рассуждая в духе Лизы, опишите, как можно вычислить разность двух интервалов. Напишите соответствующую процедуру вычитания, называемую sub-interval.
Scheme solution:
(define (sub-interval x y)
(make-interval (- (lower-bound x) (upper-bound y))
(- (upper-bound x) (lower-bound y))))
Exercise2-7 <---> Exercise2-9
Comments
| ;;Answer above is incorrect, it should be: (define (sub-interval x y)
;; since y is > x (from the make-interval procedure in the previous exercise. | ||||
| Posted by 195 at 2009-02-18 08:13:34 X | ||||
The comment above is wrong, and the answer provided is correct. We are subtracting one interval from another here, not the bounds, so there is no indication which of x and y is larger. Even if y>x your comment still makes no sense! You would be making an interval with the lower bound equal to the size of the interval y. | ||||
| Posted by 204 at 2009-06-24 12:34:48 X | ||||
I think both are "incorrect", not semanticly speaking (didn't check), but because the exercise says "Using reasoning analogous to Alyssa's". I solved it this way: (define (sub-interval x y)
analogously to the div-interval procedure. | ||||
| Posted by Blackout at 2009-08-24 18:37:06 X | ||||