sicp-ex-2.52


 ;; a 
 (define wave 
   (segments->painter (list 
                       ;; ... 
                       (make-segment (make-vect 0.44 0.7) (make-vect 0.51 0.7))))) 
  
 ;; b 
 (define (corner-split painter n) 
   (if (= n 0) 
       painter 
       (beside (below painter (up-split painter (- n 1))) 
               (below (right-split painter (- n 1)) (corner-split painter (- n 1)))))) 
  
 ;; c 
 (define (square-limit painter n) 
   (let ((combine4 (square-of-four flip-vert rotate180 
                                   identity flip-horiz))) 
     (combine4 (corner-split painter n)))) 

<< Previous exercise (2.51) | Index | Next exercise (2.53) >>


HYC

should it be n instead of (- n 1) for up-split and right-split? Since (right-split painter 0) will return painter, which makes it results different from the original corner-split.

 ;; b  
 (define (corner-split painter n) 
   (if (= n 0) 
     painter 
     (beside (below painter (up-split painter n)) 
             (below (right-split painter n) (corner-split painter (- n 1))))))