Subtraction of intervals

Using reasoning analogous to Alyssa's, describe how the difference of two intervals may be computed. Define a corresponding subtraction procedure, called sub-interval.


There are no comments yet.

Authentication required

You must log in to post a comment.

Login
(define (make-interval a b)
  (cons a b))

(define lower1 5)

(define lower2 15)

(define upper1 10)

(define upper2 25)

(define interval1 (make-interval lower1 upper1))

(define interval2 (make-interval lower2 upper2))

(check-equal?  (sub-interval interval2 interval2) '(0 . 0))
(check-equal?  (sub-interval interval2 interval1) '(10 . 15))