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
          主站蜘蛛池模板: 美姑县| 青神县| 集安市| 临城县| 灵寿县| 万荣县| 泗阳县| 封开县| 平阴县| 松溪县| 延吉市| 东兴市| 柘荣县| 灵石县| 阳曲县| 青川县| 上杭县| 宣威市| 兖州市| 温宿县| 虹口区| 密云县| 花垣县| 香港 | 洛宁县| 砚山县| 涡阳县| 弥渡县| 贡山| 靖州| 广宗县| 古交市| 宁海县| 金门县| 永康市| 龙山县| 龙泉市| 鸡西市| 佛学| 高台县| 汶川县|