diff options
| author | Steve Lee <me@xiangyangli.com> | 2016-11-29 15:19:43 +0800 |
|---|---|---|
| committer | Steve Lee <me@xiangyangli.com> | 2016-11-29 15:19:43 +0800 |
| commit | e45f3f862b41e5cda123d423b37ed53c077c1170 (patch) | |
| tree | 500596fb6a029cf0a5af70069d797cd8d7b94b93 /SICP/ch2_2_2.scm | |
| parent | 38f1804506888956e1fc95e3e405a366e17d4812 (diff) | |
| download | Personal-e45f3f862b41e5cda123d423b37ed53c077c1170.tar.xz Personal-e45f3f862b41e5cda123d423b37ed53c077c1170.zip | |
add bundle config
Diffstat (limited to 'SICP/ch2_2_2.scm')
| -rw-r--r-- | SICP/ch2_2_2.scm | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/SICP/ch2_2_2.scm b/SICP/ch2_2_2.scm index fc6ca30..ca83c07 100644 --- a/SICP/ch2_2_2.scm +++ b/SICP/ch2_2_2.scm @@ -85,3 +85,49 @@ (deep-reverse (list 3 4)) (deep-reverse (list 1 2 3)) (reverse (list 1 2 3)) + +;; Exercise2.28 + +(define (fringe items) + (if (not (pair? items)) + (list items) + (append (fringe (car items)) + (if (null? (cdr items)) + nil + (fringe (cdr items)))))) + + +(append (list 3) (list 4)) +(append (list 4) nil) +(append nil (list 4)) +(list 4) +(list 3 4) +(list nil) +(append (list nil) (list nil)) + +(define x + (list (list 1 2) (list 3 4))) +(fringe x) +(fringe (list x x)) +(list 1 2 3 4) +(list 1 2 3 4 1 2 3 4) + +(append (list 2) (list 3)) +(list 2 3) +(list (list 1 2) (list 3 4)) +(list (list 1 2) 3 4) + +;; Exercise2.29 + +(define (make-mobile left right) + (list left right)) + +(define (make-branch length structure) + (list length structure)) + +(define (left-branch mobile) + (car (mobile))) +(define (right-branch mobile) + (cdr (mobile))) + +(define branch-length) |
