1
\$\begingroup\$

From the Extended Exercise beginning in section 2.1.4, you can find exercise 2.8:

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.

I wrote the following:

(define (sub-interval x y)
  (make-interval (- (lower-bound x) (upper-bound y))
                 (- (upper-bound x) (lower-bound y))))

What do you think?

\$\endgroup\$
1
\$\begingroup\$

Looks great. Don't forget to define lower-bound and upper-bound as car and cdr respectively.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.