090305 Exercise 1.3 returns the sum of the squares of the two larger numbers

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

(define (compare x y) (- x y))
(define (sumsquares x y)(+(* x x)(* y y)))
(define (returnlarge a b c)
  (cond ((and (>= (compare a b) 0) (>= (compare c b) 0)) (sumsquares a c))
        ((and (>= (compare a c) 0) (>= (compare b c) 0)) (sumsquares a b))
        ((and (>= (compare c a) 0) (>= (compare b a) 0)) (sumsquares b c))
         )
  )
(returnlarge 3 3 2)

>18

你可能感兴趣的:(090305 Exercise 1.3 returns the sum of the squares of the two larger numbers)