Chapter 2, Building Abstractions with Data

Section - 2.2 - Hierarchical Data and the Closure Property

Exercise 2.45


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
#lang sicp

(#%require sicp-pict)

(define (split align1 align2)
  (lambda (painter n)
    (if (= n 0)
      painter
      (let (
              (smaller (
                         (split
                             align1 align2
                         )
                         painter (- n 1)
                      )
              )
           )
           (align1
                painter
                (align2 smaller smaller)
           )
      )
    )
  )  
)