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.
(define (square x) (* x x))
(square 12)Run it from the directory containing the file.
lispex sicp run exercise.scmOutput:
144The 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.
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 core | Lispex SICP | |
|---|---|---|
| File | square.lspx | exercise.scm |
| Command | lispex run square.lspx | lispex sicp run exercise.scm |
| Use | General Lispex programs | SICP study and exercises |
| Playground | Default profile | ?profile=sicp |
| Runtime | Lispex core engine | Rust 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=sicpquery 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.
npm install @lispex/sicp@1.0.0npm 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.
const { run } = require('@lispex/sicp');
const result = run('(define (square x) (* x x)) (square 12)');
console.log(result.value_display);Run it:
node square.cjsIt 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.
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.
| Resource | Limit |
|---|---|
| UTF-8 source | 1 MiB |
| Execution trace | 1,024 events and 1 MiB |
| Logical heap, execution work, and output | Fixed 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.