#lang racket
(require (planet "sicp.ss" ("soegaard" "sicp.plt" 2 1)))
(define (split first second)
(lambda (painter n)
(if (= n 0)
painter
(let ((smaller ((split first second) painter (- n 1))))
(first painter (second smaller smaller))))))
(define right-split (split beside below))
(define up-split (split below beside))
(define (corner-split painter n)
(if (= n 0)
painter
(let ((up (up-split painter (- n 1)))
(right (right-split painter (- n 1))))
(let ((top-left (beside up up))
(bottom-right (below right right))
(corner (corner-split painter (- n 1))))
(beside (below painter top-left)
(below bottom-right corner))))))
(define (square-limit painter n)
(let ((quarter (corner-split painter n)))
(let ((half (beside (flip-horiz quarter) quarter)))
(below (flip-vert half) half))))
(paint (right-split einstein 3))
(paint (up-split einstein 3))
(paint (square-limit einstein 3))
运行结果