Last active
December 29, 2015 13:19
-
-
Save idiottiger/7676375 to your computer and use it in GitHub Desktop.
homework of sicp
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
;;1.3 Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers. | |
(define (sq x)(* x x)) | |
(define (f2 x y)(if (< x y) x y)) | |
(define (f3 x y z)(f2 (f2 x y) (f2 y z))) | |
(define (sum_3 x y z)(- (+ (sq x) (sq y) (sq z)) (sq(f3 x y z)))) | |
;;1.4 implemenets: | |
;; (define (a-plus-abs-b a b) | |
;; ((if (> b 0) + -) a b)) | |
(define (a_b a b)(if(> b 0) (+ a b) (- a b))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment