sicp 2.51

Exercise 2.51.  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).

 

 

(define (below-1 painter1 painter2)
  (let ((paint-top (transform-painter painter2
                                      (make-vect 0.0 0.5)
                                      (make-vect 1.0 0.5)
                                      (make-vect 0.0 0.1)))
        (paint-bottom (transform-painter painter1
                                         (make-vect 0.0 0.0)
                                         (make-vect 1.0 0.0)
                                         (make-vect 1.0 0.5)))))
  (lambda (frame)
    (paint-top frame)
    (paint-bottom frame)))

(define (below-2 painter1 painter2)
  (rorate90 (beside ((flip-cc-270 painter1) (flip-cc-270 painter2)))))

 

你可能感兴趣的:(SICP)