summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsiddharth <s@ricketyspace.net>2021-09-16 17:12:45 -0400
committersiddharth <s@ricketyspace.net>2021-09-16 17:12:45 -0400
commit30e0a6a0f5318f7f242cddec3240ff685a6e5c23 (patch)
treecd9a884e8a00d086887f3f169464475a3c65090d
parentaab3a75414ed9ec0a747df3655d0585935c32849 (diff)
ex/2/44.rkt: do ex. 2.44
-rw-r--r--ex/2/44.rkt39
-rw-r--r--ex/2/rogers.jpgbin0 -> 25995 bytes
2 files changed, 39 insertions, 0 deletions
diff --git a/ex/2/44.rkt b/ex/2/44.rkt
new file mode 100644
index 0000000..6819778
--- /dev/null
+++ b/ex/2/44.rkt
@@ -0,0 +1,39 @@
+;;;; License: CC0-1.0
+
+#lang racket
+
+(require
+ racket/runtime-path
+ sicp-pict)
+
+(define-runtime-path rogers-file "rogers.jpg")
+
+(define rogers
+ (bitmap->painter rogers-file))
+
+(define (right-split painter n)
+ (if (= n 0)
+ painter
+ (let ((smaller (right-split painter (- n 1))))
+ (beside painter (below smaller smaller)))))
+
+(define (up-split painter n)
+ (if (= n 0)
+ painter
+ (let ((smaller (up-split painter (- n 1))))
+ (below painter (beside smaller smaller)))))
+
+(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))))))
+
+;;; Racket REPL
+;;;
+;;; https://ricketyspace.net/sicp/2.44.jpg
diff --git a/ex/2/rogers.jpg b/ex/2/rogers.jpg
new file mode 100644
index 0000000..5821c24
--- /dev/null
+++ b/ex/2/rogers.jpg
Binary files differ