Skip to content

Instantly share code, notes, and snippets.

@pandeiro
Created June 3, 2011 15:34
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 pandeiro/1006541 to your computer and use it in GitHub Desktop.
Save pandeiro/1006541 to your computer and use it in GitHub Desktop.
Scheme exercise from SICP ch 1
; Exercise 1.3: Define a procedure that takes threee numbers as arguments
; and returns the sum of the squares of the two larger numbers
(define (toptwosq x y z)
(if (and (< x y) (< x z))
(+ (* y y) (* z z))
(if (and (< y x) (< y z))
(+ (* x x) (* z z))
(+ (* x x) (* z z))
)
)
)
; Unit test for toptwosq function:
(when (not 13 (toptwosq 1 2 3)) (error "damn"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment