Exercise 2.51

Read Exercise 2.51 ~ Solution


As mentioned in the last exercise, rhe SICP language provides a transform-painter procedure that only takes 3 arguments – origin corner1 and corner2 and it returns a procedure that takes a painter argument which returns a transformed painter.

(define (below painter1 painter2)
  (let ((split-point (make-vect 0.0 0.5)))
    (let ((paint-down
           ((transform-painter (make-vect 0.0 0.0)
                               (make-vect 1.0 0.0)
                               split-point)
            painter1))
          (paint-up ((transform-painter
                      split-point
                      (make-vect 1.0 0.5)
                      (make-vect 0.0 1.0))
                     painter2)))
      (lambda (frame)
        (paint-down frame)
        (paint-up frame)))))

(define (below-2 painter1 painter2)
  (rotate90 (beside (rotate270 painter1)
                    (rotate270 painter2))))
(paint-hires (below-2 wave-painter einstein))

Leave a comment