2013年3月29日 星期五

NCNU LISP HW1


exercise 1: calculate the sum of squares

(define (>= x y)(not (< x y)))
(define (square a)(* a a))
(define (answer x y z)
        (cond ( (and (>= x z) (>= y z)) (+ (square x) (square y)))
              ( (and (>= y x) (>= z x)) (+ (square y) (square z)))
              ( (and (>= z y) (>= x y)) (+ (square z) (square x)))
        )
)

沒有留言:

張貼留言