**Exercise 1.3:** Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.

1 2 3 4 5 6 7 8 9 |
(define (square x) (* x x)) (define (sum-of-squares x y) (+ (square x) (square y))) (define (max a b) (if (> a b) a b)) (define (take-two a b c) (cond ((and (> a b) (> a c)) (sum-of-squares a (max b c))) ((and (> b a) (> b c)) (sum-of-squares b (max a c))) (else (sum-of-squares c (max a b))))) |

Just for fun another way:

1 2 3 4 5 6 |
(define (square x) (* x x)) (define (sum-of-squares a b c) (+ (square a) (square b) (square c))) (define (least a b) (if (< a b) a b)) (define (take-two a b c) (- (sum-of-squares a b c) (square (least (least a b) c)))) |