Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Last active November 2, 2019 05:25
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 chelseatroy/94d040862d6fb7b6bd9f79a87ad25259 to your computer and use it in GitHub Desktop.
Save chelseatroy/94d040862d6fb7b6bd9f79a87ad25259 to your computer and use it in GitHub Desktop.
Function Definitions
(define (find-smallest a b c)
(cond ((and (<= a b) (<= a c) a))
((and (<= b c) (<= b c) b))
((and (<= c a) (<= c b) c))
)
)
(define (largest-squared-hypotenuse a b c) (
cond ((= (find-smallest a b c) a) (+ (* b b) (* c c)))
((= (find-smallest a b c) b) (+ (* a a) (* c c)))
((= (find-smallest a b c) c) (+ (* b b) (* a a)))
)
)
(largest-squared-hypotenuse 1 2 3) ;--> 13 (3 squared plus 2 squared)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment