sicp-ex-2.51



<< Previous exercise (2.50) | Index | Next exercise (2.52) >>


 (define (below painter1 painter2) 
   (let ((split-point (make-vect 0.0 0.5))) 
     (let ((paint-bottom 
            (transform-painter painter1 
                               (make-vect 0.0 0.0) 
                               (make-vect 1.0 0.0) 
                               split-point)) 
           (paint-top 
            (transform-painter painter2 
                               split-point 
                               (make-vect 1.0 0.5) 
                               (make-vect 0.0 1.0)))) 
       (lambda (frame) 
         (paint-bottom frame) 
         (paint-top frame))))) 
  
 (define (below-2 painter1 painter2) 
   (rotate90 (beside (rotate270 painter1) (rotate270 painter2)))) 
  
 ;; Another way 
 (define (below-2 painter1 painter2) 
   (rotate270 (beside (rotate90 painter2) (rotate90 painter1)))) 
  
  
 ;; A way to do it using only the operations created in 
 ;; ex 2.50: rotate180 and rotate270 
 ;; It's a bit of a wild ride. 
  
 (define (below3 p1 p2) 
   (rotate180 (rotate270 (beside (rotate270 p1) (rotate270 p2)))))