Skip to content

Instantly share code, notes, and snippets.

@josephmosby
Created September 15, 2014 18:20
Show Gist options
  • Save josephmosby/15835c87c069015caf0d to your computer and use it in GitHub Desktop.
Save josephmosby/15835c87c069015caf0d to your computer and use it in GitHub Desktop.
Saving accomplishments in Lisp because parentheses
(define (find-largest x y z)
(cond ((and (> x y) (> x z)) x)
((and (> y z) (> y x)) y)
((and (> z x) (> z y)) z)))
(define (find-second-largest x y z)
(cond ((and (> y x) (< y z)) y)
((and (> z y) (< z x)) z)
((and (> x z) (< x y)) x)))
(define (square x) (* x x))
(define (sum-of-greatest x y z) (+ (square (find-largest x y z)) (square (find-second-largest x y z))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment