--- title: Reading SICP – 2 author: kazu634 date: 2008-11-30 wordtwit_post_info: - 'O:8:"stdClass":13:{s:6:"manual";b:0;s:11:"tweet_times";i:1;s:5:"delay";i:0;s:7:"enabled";i:1;s:10:"separation";s:2:"60";s:7:"version";s:3:"3.7";s:14:"tweet_template";b:0;s:6:"status";i:2;s:6:"result";a:0:{}s:13:"tweet_counter";i:2;s:13:"tweet_log_ids";a:1:{i:0;i:4409;}s:9:"hash_tags";a:0:{}s:8:"accounts";a:1:{i:0;s:7:"kazu634";}}' categories: - Lisp ---

Structure and Interpretation of Computer Programs (MIT Electrical Engineering and Computer Science)を読む、その2です。今回は

というようなことが書いてありました(私の理解が間違えていなければ…)。

Excercise (pp 20-21)

Excercise 1.2

Translate the following expression into prefix form

¥frac{5 + 4 + (2 - (3 - (6 + ¥frac{4}{5})))}{3(6 - 2)(2 - 7)}

(/ (+ 5 4 (- 2 (- 3 (+ 6 (/ 4 5))))) (* 3 (- 6 2) (- 2 7)))
Excercise 1.3

Define a procedure that takes 3 numbers as arguments and returns the sum of the squares of the two larger numbers.

(define (sum-of-square a b c)
(define (square n)
(* n n))
(cond [(and (< a b) (< a c)) (+ (square b) (square c))]   ; when a is the smallest
[(and (< b a) (< b c)) (+ (square a) (square c))]   ; when b is the smallest
[(and (< c a) (< c b)) (+ (square a) (square b))])) ; when c is the smallest