sicp-ex-2.50


 (define (flip-horiz painter) 
   (transform-painter painter 
                      (make-vect 1.0 0.0) 
                      (make-vect 0.0 0.0) 
                      (make-vect 1.0 1.0))) 
  
 (define (rotate180 painter) 
   (transform-painter painter 
                      (make-vect 1.0 1.0) 
                      (make-vect 0.0 1.0) 
                      (make-vect 1.0 0.0))) 
  
 (define (rotate270 painter) 
   (transform-painter painter 
                      (make-vect 0.0 1.0) 
                      (make-vect 0.0 0.0) 
                      (make-vect 1.0 1.0))) 

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


dudrenov

 ;; That's one way of doing it. 
  
  
  
 (define (flip-horiz painter) 
   (transform-painter painter 
                      (make-vect 1.0 0.0) 
                      (make-vect 0.0 0.0) 
                      (make-vect 1.0 1.0))) 
  
 (define (repeated fn t) 
   (if (= t 1) 
       fn 
       (lambda (x) 
         (fn ((repeated fn (- t 1)) 
              x))))) 
  
 (define (rotate180 painter) 
   ((repeated  rotate90 2) painter)) 
  
 (define (rotate270 painter) 
   ((repeated rotate90 3) painter))