sicp 2.45

 

Exercise 2.45.  Right-split and up-split can be expressed as instances of a general splitting operation. Define a procedure splitwith the property that evaluating

 

(define right-split (split beside below))
(define up-split (split below beside))

 

produces procedures right-split and up-split with the same behaviors as the ones already defined.

 

 

(define right-split (split beside below))
(define up-split (split below beside))

(define (split direction1 direction2)
  (lambda (painter n)
    (if (= n 0)
        painter
        (let ((smaller ((split direction1 direction2) painter (- n 1))))
          (direction1 painter (direction2 smaller smaller))))))

你可能感兴趣的:(SICP)