Skip to content

Instantly share code, notes, and snippets.

@iximiuz
Last active August 29, 2015 14:02
Show Gist options
  • Save iximiuz/c0c30dc840864e80a951 to your computer and use it in GitHub Desktop.
Save iximiuz/c0c30dc840864e80a951 to your computer and use it in GitHub Desktop.
Sum of squares of two biggest numbers (SICP excercise)
; pen test on functional programming
(define (min-2 a b) (if (> a b) b a))
(define (min-3 a b c) (min-2 (min-2 a b) (min-2 b c)))
(define (sq x) (* x x))
(define (foo a b c) (cond ((= a (min-3 a b c)) (+ (sq b) (sq c)))
((= b (min-3 a b c)) (+ (sq a) (sq c)))
(else (+ (sq a) (sq b)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment