2.45 Exercise 2.45
Writing up-split, it should have been apparent that it was almost identical to right-split. Now we generalize it into a general split procedure:
(define (split macro-op micro-op) (define (apply-split painter n) (if (= n 0) painter (let ((smaller (apply-split painter (- n 1)))) (macro-op painter (micro-op smaller smaller))))) apply-split)
We cannot use a normal lambda because the procedure we return has to call itself. I chose to use an internal define to create the procedure and to return it without calling it after.