Skip to main content

SICP Exercise Pointers

This module earns its content from implemented artifacts (the interpreter, the numerical library, the traces) rather than worked problem sets. But SICP's exercises are exceptionally well-crafted and a targeted selection reinforces every cluster. Use these as optional deepening, not as required completion.

How To Use This Page

  1. Finish the relevant concept page first.
  2. Attempt the matching practice task from memory.
  3. Only then open the matching SICP exercise.
  4. Keep a mistake log tagged with entries like used car/cdr above the barrier, closure captured the wrong environment, evaluated both branches of if, reached for set! before trying an accumulator, non-tail recursion killed my Python stack.

Cluster 1: Abstraction as the Engineering Move

SICP §1.1 and §2.1 both carry this cluster. A good minimum is to do three or four of these.

  • SICP 1.3 -- square-root by Newton's method. Practice procedural abstraction by factoring out good-enough?, improve, sqrt-iter.
  • SICP 1.6 -- Alyssa's new-if as an ordinary procedure. This is the clearest single illustration of why if must be a special form (see Concept 08 and Quiz Q9).
  • SICP 2.1 -- design the rational-number ADT. Normalize to lowest terms.
  • SICP 2.2 -- design a point and segment ADT with constructors, selectors, and a midpoint-segment operation.
  • SICP 2.3 -- make-rect, width-rect, height-rect with two representations. The classic exercise on picking constructors and selectors.
  • SICP 2.4 / 2.5 -- alternate representations of cons using only procedures -- a shock therapy for "what is data, really?"

Chunk reinforcements:

Cluster 2: Higher-Order Procedures and Closures

  • SICP 1.29 -- Simpson's rule as a HOF.
  • SICP 1.30 -- sum as an iterative process (tail-recursive helper). Preview of Cluster 3.
  • SICP 1.31 / 1.32 -- product and accumulate as direct generalizations of sum.
  • SICP 1.33 -- filtered-accumulate -- the HOF that merges filter and reduce in one shot.
  • SICP 1.40 / 1.41 / 1.42 -- cubic, double, compose. A short ladder into composition.
  • SICP 1.43 / 1.46 -- repeated application; iterative improvement as a HOF. Closures over procedures.
  • SICP 2.23 -- for-each, written in terms of other HOFs.

Chunk reinforcements:

Cluster 3: Evaluation Models

  • SICP 1.4 -- define a-plus-abs-b using an operator chosen by if. Small but crisp; forces substitution thinking.
  • SICP 1.5 -- Ben's applicative/normal-order test. Canonical way to observe the difference, with a divergent procedure.
  • SICP 1.9 -- trace two different definitions of + using substitution; classify one as recursive process, the other as iterative.
  • SICP 3.9 -- trace factorial in the environment model. The exercise for drawing frames.
  • SICP 3.10 -- trace make-withdraw in the environment model. Adds the twist that let is ((lambda (...) ...) ...) behind the scenes.
  • SICP 3.11 -- trace make-account similarly; confirms closures + frames.

Chunk reinforcements:

Cluster 4: Metacircular and Interpreter Design

The exercises in Chapter 4 are substantial; pick two or three.

  • SICP 4.1 -- change list-of-values to enforce left-to-right (or right-to-left) argument evaluation. One line of code; deep ramifications.
  • SICP 4.2 -- Louis's "move application before conditionals" bug. The quiz-style question in book form.
  • SICP 4.3 -- rewrite eval as data-directed dispatch (a table of handlers keyed by tag).
  • SICP 4.4 -- add and and or as special forms, then as derived expressions.
  • SICP 4.6 -- implement let as a derived expression.
  • SICP 4.7 -- implement let* in terms of let.
  • SICP 4.22 -- extend the analyzing evaluator to handle let.
  • SICP 5.1 -- draw a register-machine diagram for GCD. Connects interpretation to the machine layer (motivates Concept 12).

Chunk reinforcements:

Cluster 5: State, Mutation, and Language Design

  • SICP 3.1 -- make-accumulator. First closure over mutable state.
  • SICP 3.2 -- make-monitored. Adds a how-many-calls? message.
  • SICP 3.3 / 3.4 -- make-account with passwords. Discipline for what counts as object identity.
  • SICP 3.8 -- a procedure whose effect depends on evaluation order. Concrete proof that order of operand evaluation is observable once mutation is in the language.
  • SICP 3.50 / 3.52 -- stream map and lazy evaluation traces. Concrete training in "what happened when."
  • SICP 3.53 / 3.54 -- self-referential streams. Fibonacci as a stream equation.
  • SICP 3.38 / 3.39 -- concurrency: predicting possible outcomes of interleaved assignments. Quick, eye-opening.
  • SICP 3.42 / 3.43 -- reasoning about serializers and shared mutable state.

Chunk reinforcements:

Suggested Minimum Set

If you can only afford one exercise per cluster, do these:

  • Cluster 1: SICP 2.2 (segments ADT) -- shortest worked data-abstraction example
  • Cluster 2: SICP 1.33 (filtered-accumulate) -- highest leverage HOF exercise
  • Cluster 3: SICP 3.10 (make-withdraw trace) -- the canonical environment-model drill
  • Cluster 4: SICP 4.1 (evaluation order) -- the one-line change that teaches everything
  • Cluster 5: SICP 3.1 (make-accumulator) -- minimal closure-with-state exercise

Completion Checklist

  • At least one exercise completed per cluster
  • Every exercise solved independently before opening the book's answer discussion
  • A mistake log with at least 6 real, tagged entries
  • At least one exercise re-attempted cold after a delay of ≥ 2 days