Skip to content

Instantly share code, notes, and snippets.

@idiottiger
Last active December 29, 2015 13:19
Show Gist options
  • Save idiottiger/7676375 to your computer and use it in GitHub Desktop.
Save idiottiger/7676375 to your computer and use it in GitHub Desktop.
homework of sicp
;;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