【SICP练习】79 练习2.51

        练习2.51

通过书中前面的内容,我们知道below中来将框架分成上下两部分,而beside将框架分成左右两部分。因此,below定义如下:

(define (below painter1 painter2)

  (let ((split-point (make-vect 0.0 0.5)))

     (let ((paint-top (transform-painter painter2

                                      split-point

                                      (make-vect 1.0 0.5)

                                      (make-vect 0.0 1.0)))

          (paint-down (transform-painterpainter1

                                        (make-vect 0.0 0.0)

                                        (make-vect 1.0 0.0)

                                        split-point)))

       (lambda (frame)

            (paint-top frame)

            (paint-down frame)))))

另一种利用上一题中的rotate270等可以很容易的实现:

(define (below painter1 painter2)

     (lambda (frame)

         ((flip-horiz

              (rotate90

                  (beside

                      (rotate270

                         (flip-horizpainter1))

                      (rotate270

                         (flip-horizpainter2)))))

           frame)))

版权声明:本文为 NoMasp柯于旺 原创文章,如需转载请联系本人。

posted @ 2015-02-22 14:05  nomasp  阅读(154)  评论(0编辑  收藏  举报