Skip to content

Instantly share code, notes, and snippets.

@yakreved
Last active December 21, 2015 00:18
Show Gist options
  • Save yakreved/6218785 to your computer and use it in GitHub Desktop.
Save yakreved/6218785 to your computer and use it in GitHub Desktop.
sicp 2.8 Рассуждая в духе Лизы, опишите, как можно вычислить разность двух интервалов. Напишите соответствующую процедуру вычитания, называемую sub-interval.
(define (make-interval a b) (cons a b))
(define (upper-bound x) (car x))
(define (lower-bound x) (cdr x))
(define (sub-interval a b)
(make-interval
(- (upper-bound a) (lower-bound b))
(- (lower-bound a) (upper-bound b))
)
)
;(make-interval 4 5)
(sub-interval (make-interval 4 5) (make-interval 1 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment