summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ex/2/51.rkt3
-rw-r--r--ex/2/52.rkt23
2 files changed, 25 insertions, 1 deletions
diff --git a/ex/2/51.rkt b/ex/2/51.rkt
index 8f28d76..347bca3 100644
--- a/ex/2/51.rkt
+++ b/ex/2/51.rkt
@@ -2,11 +2,12 @@
#lang racket
+(provide beside below)
+
(require "46.rkt")
(require "49.rkt")
(require "50.rkt")
-
(define (beside painter1 painter2)
(let ((split-point (make-vect 0.5 0.0)))
(let ((paint-left
diff --git a/ex/2/52.rkt b/ex/2/52.rkt
index 92fcf08..bfbc7ac 100644
--- a/ex/2/52.rkt
+++ b/ex/2/52.rkt
@@ -5,6 +5,7 @@
(require "46.rkt")
(require "48.rkt")
(require "49.rkt")
+(require "51.rkt")
(define (wavex->painter)
(let* ((h-ls (make-vect 0.426 0.000)) ; head - left start
@@ -78,3 +79,25 @@
(make-segment wll-is wll-ie)
(make-segment wrl-os wrl-oe)
(make-segment wrl-is wrl-ie)))))
+
+
+(define (split left right)
+ (lambda (painter n)
+ (if (= n 0)
+ painter
+ (let ((smaller ((split left right) painter (- n 1))))
+ (left painter (right smaller smaller))))))
+
+(define right-split (split beside below))
+(define up-split (split below beside))
+
+(define (corner-split-single painter n)
+ (if (= n 0)
+ painter
+ (let ((up (up-split painter (- n 1)))
+ (right (right-split painter (- n 1))))
+ (let ((top-left up)
+ (bottom-right right)
+ (corner (corner-split-single painter (- n 1))))
+ (beside (below painter top-left)
+ (below bottom-right corner))))))