SICP Exercise 2.51

Question

Define the below operation for painters. Below takes two painters as arguments. The resulting painter, given a frame, draws with the first painter in the bottom of the frame and with the second painter in the top. Define below in two different ways – first by writing a procedure that is analogous to the beside procedure given above, and again in terms of beside and suitable rotation operations (from Exercise 2.50).

Answer

(define (below-1 p1 p2)
  (let ((split-point (make-vect 0 0.5)))
    (let ((paint-low  (transform-painter
                        p1
                        (make-vect 0 0)
                        (make-vect 1 0)
                        split-point))
          (paint-high (transform-painter
                        p2
                        split-point
                        (make-vect 1 0.5)
                        (make-vect 0 1))))
      (λ (frame)
        (paint-low frame)
        (paint-high frame)))))

(define (below-2 p1 p2)
  (rotate270 (beside (rotate90 p1) (rotate90 p2))))

Both of these produce the exact same output.