public
Description: SICP Exercises
Homepage:
Clone URL: git://github.com/jamie/sicp.git
sicp /
name age message
directory 1.1.3/ Thu Jan 22 09:56:57 -0800 2009 some instructors manual exercises [jamie]
directory 1.1.6/ Thu Jan 22 11:11:14 -0800 2009 implement remaining sec 1.1 instructors exercises [jamie]
directory 1.1.7/ Thu Jan 22 11:11:14 -0800 2009 implement remaining sec 1.1 instructors exercises [jamie]
directory 1.1.8/ Thu Jan 22 10:27:33 -0800 2009 q and a for instructors manual e1.7 and 1.8 [jamie]
file clojure.jar Sun Jan 04 11:08:36 -0800 2009 Start with clojure_20081217 [jamie]
file readme.md Tue Jan 20 08:10:29 -0800 2009 reorganize file structure [jamie]
file repl Sun Jan 04 11:10:11 -0800 2009 add a repl shortcut [jamie]
readme.md

SICP Exercises

Root directories are the section in the text, filenames are exercise number. Plain text responses in .txt files, scheme source in .ss files (tested with PLT Scheme), clojure source in .clj files (tested with Clojure v20081217).

Also included are exerciese from the Instructor's Manual, prefixed with an 'M'.

Support Files

I've included clojure.jar, v20081217, and a simple wrapper bash script that will open up the Clojure REPL.

Notes

There are some special form differences between the scheme presented in SICP and Clojure. I'm documenting them here as I go along.

Scheme                                Clojure

(define a 3)                          (def a 3)

(cond ((= a 4) 6)                     (cond (= a 4) 6
      ((= b 4) (+ 6 7 a))                   (= b 4) (+ 6 7 a)
      (else 25))                            :else 25)

(define (a-plus-abs-b a b)            (defn a-plus-abs-b [a b]
  ((if (> b 0) + -) a b))               ((if (> b 0) + -) a b))

                                      ; The JVM doesn't automatically support
                                      ; tail-call optimization, so Clojure
                                      ; provides a keyword to hint it
(defn sqrt-iter [guess x]             (defn sqrt-iter [guess x]
  (if (good-enough? guess x)            (if (good-enough? guess x)
      guess                                 guess
      (sqrt-iter (improve guess x)          (recur (improve guess x)
                 x)))                              x)))