Skip to content

Instantly share code, notes, and snippets.

@kEND
Forked from redsquirrel/gist:189192
Created September 19, 2009 23:03
Show Gist options
  • Save kEND/189625 to your computer and use it in GitHub Desktop.
Save kEND/189625 to your computer and use it in GitHub Desktop.
Exercise 1.3
(define (square x) (* x x))
(define (sum-of-squares x y) (+ (square x) (square y)))
(define (larger x y) (if (> x y) x y))
(define (sum-squares-of-largest-two x y z)
(cond ((and (> x y) (> x z)) (sum-of-squares x (larger y z)))
((and (> y x) (> y z)) (sum-of-squares y (larger x z)))
(else (sum-of-squares z (larger x y)))
))
(= 41 (sum-squares-of-largest-two 3 4 5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment