SICP Study Guide

Run a complete Scheme exercise, choose a study environment, and distinguish SICP commands from ordinary Lispex commands.

You can study SICP by running Scheme exercises with the Lispex SICP language profile. Start with a file that squares a number, then choose the course site, CLI, or JavaScript API for further work.

SICP is Structure and Interpretation of Computer Programs, a book that teaches computation using Scheme. Lispex provides the Scheme features used for this study in a separate language profile, a named set of language features.

Run your first exercise

Install Lispex using First Program. Save this complete program as exercise.scm.

LISPEX
(define (square x) (* x x))
(square 12)

Run it from the directory containing the file.

SH
lispex sicp run exercise.scm

Output:

144

The command exits with code 0 and creates no files. The procedure square multiplies its argument by itself, so (square 12) gives 144. The CLI prints the program's output and final value.

In a POSIX shell, you can pass the same file through standard input.

SH
cat exercise.scm | lispex sicp run -

This also prints 144, exits with code 0, and creates no files.

Choose the command for the language profile

The SICP and ordinary core profiles are separate runtime products. The command selects the profile; the filename extension alone does not switch it.

Ordinary Lispex coreLispex SICP
Filesquare.lspxexercise.scm
Commandlispex run square.lspxlispex sicp run exercise.scm
UseGeneral Lispex programsSICP study and exercises
PlaygroundDefault profile?profile=sicp
RuntimeLispex core engineRust profile built into Native; @lispex/sicp WASM in npm and JavaScript

To try the core command, save the same program above as square.lspx. It also prints 144, exits with code 0, and creates no files.

If you use lispex run exercise.scm, the command prints this error and exits with code 2:

lispex run: .scm requires `lispex sicp run <file.scm>`

A failed SICP run stops on the selected engine. It does not retry on another engine. The npm CLI lispex uses the separate @lispex/sicp@1.0.0 package for SICP.

Choose where to study

  • sicp.io offers lessons by chapter, editable examples, execution results, and a map of supported topics. Courses are available in English, Korean, and Russian.
  • The SICP Playground runs an exercise in your browser. The profile=sicp query selects SICP; the ordinary Playground uses the core profile.
  • The CLI runs local files such as exercise.scm.
  • The JavaScript API returns the result and an execution trace, a record of evaluation steps, for use in an application.

Use the JavaScript API

For direct API use, install the package in a Node.js 18 or later project.

SH
npm install @lispex/sicp@1.0.0

npm installs version 1.0.0 under node_modules/@lispex/sicp and records the dependency in the project's package files. A successful install exits with code 0; npm's summary depends on the project.

Save this as square.cjs in that project.

JS
const { run } = require('@lispex/sicp');

const result = run('(define (square x) (* x x)) (square 12)');
console.log(result.value_display);

Run it:

SH
node square.cjs

It prints 144, exits with code 0, and creates no files. value_display is the result formatted for display. The observation field contains the structured execution result in sicp-observation/v1 format. The trace field contains the steps in lispex-trace/v1 format.

In a browser application that resolves npm package imports and serves WASM files, use the browser entry point.

JS
const { createSicpRuntime } = await import('@lispex/sicp/browser');

const runtime = await createSicpRuntime();
const result = runtime.run('(define (square x) (* x x)) (square 12)');
console.log(result.value_display);

The browser console shows 144.

Understand execution limits and records

The WASM module has no external imports. After loading, it runs in memory on the selected engine. The application operator configures process and network isolation.

ResourceLimit
UTF-8 source1 MiB
Execution trace1,024 events and 1 MiB
Logical heap, execution work, and outputFixed runtime limits

The API records what happened during an educational run. Lispex Vouch provides publisher authentication, recipient trust policy, current re-execution, and local acceptance checks. The calling application decides whether to perform an external action.

For compatibility details, the published comparison data identifies the shipped WASM and 26 versioned examples run with recorded limits. It also identifies four external Scheme implementations and records their measurements, disagreements, and exclusions. The SICP book text and comparison example sources have separate licenses and are distributed separately from the runtime package.

Current product catalog