Created
April 6, 2010 06:38
-
-
Save pathsny/357296 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (make-interval a b) (cons a b)) | |
(define (lower-bound int) (car int)) | |
(define (upper-bound int) (cdr int)) | |
(define (add-interval x y) | |
(make-interval (+ (lower-bound x) (lower-bound y)) | |
(+ (upper-bound x) (upper-bound y)))) | |
(define (sub-interval x y) | |
(make-interval (- (lower-bound x) (upper-bound y)) | |
(- (upper-bound x) (lower-bound y)))) | |
(define r1 (make-interval 4.2 4.5)) | |
(define r2 (make-interval 4.2 4.5)) | |
(add-interval (sub-interval r2 r1) r1) ; (3.9000000000000004 . 4.8) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment