learning-sicp

My embarrassing half assed SICP run.
git clone https://kaka.farm/~git/learning-sicp
Log | Files | Refs

exercise-3.scm (663B)


      1 (define-library (sicp solutions chapter-1 exercise-3)
      2   (import
      3    (scheme base)
      4    (srfi srfi-64)
      5    (only (sicp solutions chapter-1 exercise-1) sum-of-squares))
      6   (export sum-of-squares-of-two-largest-out-of-three)
      7 
      8   (begin
      9 
     10     #!
     11 
     12     *Exercise 1.3:* Define a procedure that takes three numbers as
     13     arguments and returns the sum of the squares of the two larger
     14     numbers.
     15 
     16     !#
     17 
     18     (define (sum-of-squares-of-two-largest-out-of-three a b c)
     19       (if (< a b)
     20           (if (< c a)
     21               (sum-of-squares a b)
     22               (sum-of-squares c b))
     23           (if (< c b)
     24               (sum-of-squares b a)
     25               (sum-of-squares c a))))))