-
Notifications
You must be signed in to change notification settings - Fork 0
/
2-45.rkt
33 lines (28 loc) · 858 Bytes
/
2-45.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#lang sicp
(#%require sicp-pict)
(define (split f1 f2)
(define (proc painter n)
(if (= n 0)
painter
(let ((smaller (proc painter (- n 1))))
(f2 painter (f1 smaller smaller)))))
proc)
(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))))))
(paint (up-split einstein 1))
(newline)
(paint (right-split einstein 1))
(newline)
(paint (corner-split einstein 1))
(newline)
(paint (corner-split einstein 4))