Created
November 6, 2010 04:45
-
-
Save robertpostill/665205 to your computer and use it in GitHub Desktop.
Third part of SICP exercise 1.3
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 (smallest-of-the-two x y) | |
(if (<= x y) | |
x | |
y)) | |
(define (smallest-of-the-two? x y) | |
(if (= (smallest-of-the-two x y) x) | |
true | |
false)) | |
(define (smaller-than-thou x y z) | |
(if (and | |
(smallest-of-the-two? x y) | |
(smallest-of-the-two? x z)) | |
x | |
false)) | |
(define (smallest-of-the-three a b c) | |
(or | |
(smaller-than-thou a b c) | |
(smaller-than-thou b a c) | |
(smaller-than-thou c a b))) | |
(define (add-the-two-largest a b c) | |
(define remainder (smallest-of-the-three a b c)) | |
(define subtotal (+ a b c)) | |
(- subtotal remainder)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment