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
posted on 2009-03-05 19:56
lzj520 阅读(221)
评论(0) 编辑 收藏 所属分类:
个人学习日记 、
sicp