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 閱讀(231) 評論(0)  編輯  收藏 所屬分類: 個人學習日記sicp
          主站蜘蛛池模板: 永寿县| 长子县| 永仁县| 西乡县| 象山县| 万安县| 遂昌县| 黄龙县| 怀化市| 遂平县| 乌鲁木齐县| 通渭县| 光山县| 三门峡市| 建始县| 德昌县| 灵武市| 襄垣县| 垣曲县| 泽州县| 仲巴县| 大埔区| 灵寿县| 思南县| 卫辉市| 平陆县| 墨玉县| 通江县| 定远县| 双辽市| 吉木萨尔县| 双峰县| 永登县| 黄梅县| 丰镇市| 郯城县| 甘德县| 吉木萨尔县| 乐山市| 白玉县| 博罗县|