Wednesday, December 13, 2006

The First MIT Scheme's program(SICP's homework)

Dont forget parentheses in your program!I use the Scheme IDE which MIT website given us for suggestion.

Exercise 1.3. Define a procedure that takes three numbers as arguments and returns the sum of the two larger numbers.

Shawn@copyleft

(define a 200)
(define b 300)
(define c 100)
(define (max)
(cond ((> a b)
(and (> a c) a))
((> b c)
(and (> b a) b))
(else c)))

(define (second)
(cond ((= m b)
(cond (> (- b a) (- b c))
(- b a)
(else (- b c))))))


(define m (max))
(+ m (second))

No comments: