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 閱讀(228) 評論(0)  編輯  收藏 所屬分類: 個人學習日記 、sicp
          主站蜘蛛池模板: 阜康市| 孟连| 册亨县| 昌平区| 平乡县| 惠安县| 福清市| 金溪县| 巩义市| 连江县| 承德市| 宽甸| 罗定市| 临沭县| 全椒县| 陇西县| 垦利县| 英吉沙县| 柳江县| 怀安县| 泌阳县| 措勤县| 大同市| 缙云县| 东乡县| 盐源县| 梓潼县| 仁怀市| 阿图什市| 北川| 赞皇县| 托里县| 乌鲁木齐县| 咸丰县| 绥江县| 新兴县| 勃利县| 门源| 隆昌县| 梅河口市| 长泰县|