2008-05-21から1日間の記事一覧

Exercise 1.5

(define (p) (p)) (define (test x y) (if (= x 0) 0 y)) Then we evaluates the expression (test 0 (p)) What behavior will it with an interpreter that uses applicative-order evaluation? (test 0 (p)) ->(test 0 (p)) ->(test 0 (p)) ->.....When th…

Exercise 1.4

Use this observation to describe the behavior of the following procedure; (define (a-plus-abs-b a b) ((if (> b 0) + -) a b)) > (a-plus-abs-b 1 5) ->6 > (a-plus-abs-b 1 -5) ->6 Scheme can allows for combinations whose operators are compound…

Exercise 1.3

(define (square x) (* x x)) (define (sum-of-square x y) (+ (square x) (square y))) (define (top-two-sum-square a b c) (cond ((and (>= b a) (>= c a)) (sum-of-square b c)) ((and (>= a b) (>= c b)) (sum-of-square c a)) (else (sum-of-square a …

Exercise 1.2

Translate the following expression into prefix form 5+4+(2-(3-(6+4/5)))/3(6-2)(2-7) (/ (+ 5 4 (- 2 (- 3 (+ 6 (/ 4 5))))) (* 3 (- 6 2) (- 2 7))) ->-0.246

Exercise 1.1

I just write the results... 10 ->10 (+ 5 3 4) ->12 (- 9 1) ->8 (/ 6 2) ->3 (+ (* 2 4) (- 4 6)) ->6 (define a 3) (define b (+ a 1)) (+ a b (* a b)) ->19 (= a b) ->false (if (and (> b a) (< b (* a b))) b a) ->4 (cond ((= a 4) 6) ((= b 4) (+ …

久々の更新…SICP。

更新が前回から開いてしまいました…。 本当ならば、毎日更新できるのが理想なんですがなかなかそうもいかず。 就職活動も終わりましたので、ぼちぼち時間作ってやります! スローペースになりそうですが。。。