Created
June 3, 2011 15:34
-
-
Save pandeiro/1006541 to your computer and use it in GitHub Desktop.
Scheme exercise from SICP ch 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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