blob: 1a8be0e9867f9853c6332d23f84cd0b6499691a5 (
about) (
plain) (
blame)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#
msgid ""
msgstr ""
msgid "title: Debit Reading Session - SICP solutions pt.1"
msgstr ""
msgid "date: 2021-06-08"
msgstr ""
msgid "layout: post"
msgstr ""
msgid "lang: en"
msgstr ""
msgid "ref: debit-reading-session-sicp-solutions-pt-1"
msgstr ""
msgid ""
";; 1.41\n"
"(define (double f)\n"
" (lambda (x)\n"
" (f (f x))))\n"
"\n"
"\n"
":;; 1.42\n"
"(define (compose f g)\n"
" (lambda (x)\n"
" (f (g x))))\n"
"\n"
"\n"
";;; 1.43\n"
"(define (repeated f n)\n"
" (if (= 1 n)\n"
" identity\n"
" (comp (repeated f (dec n)))))\n"
"\n"
"\n"
";;; 2.27\n"
"(define (map-tree node-fn leaf-fn tree)\n"
" (cond\n"
" ((null? tree) tree)\n"
" ((not (pair? tree)) (leaf-fn tree))\n"
" (else\n"
" (node-fn\n"
" (cons (map-tree node-fn leaf-fn (car tree))\n"
" (map-tree node-fn leaf-fn (cdr tree)))))))\n"
"\n"
"(define (map-nodes f tree)\n"
" (map-tree f identity tree))\n"
"\n"
"(define (deep-reverse x)\n"
" (map-nodes reverse x))\n"
"\n"
"\n"
";;; 2.28\n"
"(define (flatten tree)\n"
" (define (rec acc t)\n"
" (cond\n"
" ((null? t) acc)\n"
" ((not (pair? t)) (cons t acc))\n"
" (else\n"
" (rec (rec (cdr t) acc)\n"
" (car t)))))\n"
" (rec nil tree))\n"
"\n"
"\n"
";;; 2.30\n"
"(define (square-tree tree)\n"
" (map-leaves square tree))\n"
"\n"
"\n"
";;; 2.31\n"
"(define square-tree map-leaves) ; ha!\n"
"\n"
"\n"
";;; 2.32\n"
"TODO\n"
msgstr ""
msgid "FYI: I just typed those in, I didn't yet test them yet."
msgstr ""
|