From e72d38e97cb432fd419ef8489a10a3dcffff9ffe Mon Sep 17 00:00:00 2001 From: siddharth ravikumar Date: Thu, 25 Aug 2022 20:05:23 -0400 Subject: ex: 52.rkt: add `corner-split-single` --- ex/2/52.rkt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'ex/2/52.rkt') 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)))))) -- cgit v1.2.3