;
;
; Exercise 1.3 define a procedure which takes three numbers and returns the sum of squares of larger two numbers
;
;
(begin
(define (proc a b c)
(define (square x) (* x x))
(define (larger x y )
(cond ( ( > x y) x)
( else y)
)
)
(define (smaller x y )
(cond ( ( > x y) y)
( else x)
)
)
( +
(square (smaller (larger a b) c ) )
(square (larger (larger a b) c ) )
)
)
(display (proc 10 20 30)) (newline)
(display (proc 1 2 3)) (newline)
)
1 day ago
1 comment:
(define (greatest x y) (cond ((> x y) x) (else y)))
(define (square x) (* x x))
(define (func a b c) (+ (square
(greatest a b)) (square (greatest b c))))
Post a Comment