sicp-ex-2.45



<< Previous exercise (2.44) | Index | Next exercise (2.46) >>


jz

  
 (define (split orig-placer split-placer) 
   (lambda (painter n) 
     (cond ((= n 0) painter) 
           (else 
            (let ((smaller ((split orig-placer split-placer) painter (- n 1)))) 
              (orig-placer painter (split-placer smaller smaller))))))) 
  


brave brother

i think explicit internal func makes it clearer. but the same sure.

  
 (define (split f g) 
   (define (rec painter n) 
     (if (= n 1) 
         painter 
         (let ((smaller (rec painter (- n 1)))) 
           (f painter (g smaller smaller))))) 
   rec)