Skip to content

Instantly share code, notes, and snippets.

@jimweirich
Forked from redsquirrel/gist:189192
Created September 18, 2009 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimweirich/189242 to your computer and use it in GitHub Desktop.
Save jimweirich/189242 to your computer and use it in GitHub Desktop.
;; SICP 1.3
;; Exercise 1.3. Define a procedure that takes three numbers as
;; arguments and returns the sum of the squares of the two larger
;; numbers.
(define (square x) (* x x))
(define (sum-of-squares a b)
(+ (square a) (square b)) )
(define (sum-of-two-largest-squares a b c)
(cond ((and (< a b) (< a c))
(sum-of-squares b c))
((and (< b a) (< b c))
(sum-of-squares a c))
(else
(sum-of-squares a b)) ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment