# 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 ""