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 閱讀(232) 評論(0)  編輯  收藏 所屬分類: 個人學習日記sicp
          主站蜘蛛池模板: 乡宁县| 剑川县| 赤峰市| 固安县| 泰兴市| 绩溪县| 三台县| 灯塔市| 永昌县| 铅山县| 阳新县| 浪卡子县| 长白| 深水埗区| 新丰县| 蓬莱市| 甘南县| 延吉市| 隆德县| 拜城县| 临桂县| 福清市| 河津市| 保山市| 灌云县| 浮山县| 商丘市| 吉木乃县| 高唐县| 静安区| 贡嘎县| 辽阳县| 京山县| 丽江市| 门头沟区| 泰兴市| 即墨市| 利津县| 柘荣县| 宝山区| 额尔古纳市|