問題2.52 – SICP(計算機プログラムの構造と解釈)その66

問題2.52

a. wave に笑っているような線分を加える

(define wave
  (segments->painter
    (list (make-segment (make-vect 0.35 0.85) (make-vect 0.40 1.00))
          (make-segment (make-vect 0.65 0.85) (make-vect 0.60 1.00))
          (make-segment (make-vect 0.35 0.85) (make-vect 0.40 0.65))
          (make-segment (make-vect 0.65 0.85) (make-vect 0.60 0.65))
          (make-segment (make-vect 0.50 0.75) (make-vect 0.42 0.78)) ;; 口
          (make-segment (make-vect 0.50 0.75) (make-vect 0.58 0.78)) ;; 口
          (make-segment (make-vect 0.60 0.65) (make-vect 0.75 0.65))
          (make-segment (make-vect 0.40 0.65) (make-vect 0.30 0.65))
          (make-segment (make-vect 0.75 0.65) (make-vect 1.00 0.35))
          (make-segment (make-vect 0.60 0.45) (make-vect 1.00 0.15))
          (make-segment (make-vect 0.60 0.45) (make-vect 0.75 0.00))
          (make-segment (make-vect 0.50 0.30) (make-vect 0.60 0.00))
          (make-segment (make-vect 0.30 0.65) (make-vect 0.15 0.60))
          (make-segment (make-vect 0.30 0.60) (make-vect 0.15 0.40))
          (make-segment (make-vect 0.15 0.60) (make-vect 0.00 0.85))
          (make-segment (make-vect 0.15 0.40) (make-vect 0.00 0.65))
          (make-segment (make-vect 0.30 0.60) (make-vect 0.35 0.50))
          (make-segment (make-vect 0.35 0.50) (make-vect 0.25 0.00))
          (make-segment (make-vect 0.50 0.30) (make-vect 0.40 0.00)))))

(wave canvas-frame)

SICP 問題2.52a

b. cprner-split で構成されるパターンを変更する

例えば、up-splitright-split のイメージのコピーを2つ使う代わりに1つだけのコピーを使うように変更する。

(define (up-split painter n)
  (if (= n 0)
      painter
      (below painter (up-split painter (- n 1)))))

(define (right-split painter n)
  (if (= n 0)
      painter
      (beside painter (right-split painter (- n 1)))))

((corner-split wave 3) canvas-frame)

SICP 問題2.52b

c. square-limitsquare-of-four を使う版を、隅を異なるパターンに変更する

(define (square-limit painter n)
  (let ((combine4 (square-of-four flip-horiz identity
                                  rotate180 flip-vert)))
       (combine4 (corner-split (flip-horiz painter) n))))

((square-limit wave 3) canvas-frame)

SICP 問題2.52c

計算機プログラムの構造と解釈
ジェラルド・ジェイ サスマン ジュリー サスマン ハロルド エイブルソン
ピアソンエデュケーション
売り上げランキング: 6542
«
»