run-and-show prints its :running frame (bold Checking exercises/<dir>/<name>.lisp ...) before spawning the subprocess, so the screen stays alive while the pipe is silent. When the run returns, keys queued while it ran are discarded; keys already queued when the run started survive, so scripted sessions still work. This fixes the stray-n auto-advance after a save. The reader thread now sets an open-p flag at EOF; prompt-line reads one answer line through the input queue and returns NIL at EOF. A 50ms grace at watch start lets piped stdin land before the first frame. README notes that keys typed mid-run are ignored.
Lisplings
/
/
/
/\
/ \
/ \
Small exercises to get you used to reading and writing Common Lisp code - recommended in parallel with a book like Practical Common Lisp.
Lisplings is what Rustlings is to Rust: a watcher runs the exercise you are on, you fix it in your editor, and saving the file runs it again. Everything, including the exercises, the checks, and lisplings itself, is plain Common Lisp.
Getting started
You need SBCL. Any recent version works; no libraries beyond it.
Without nix
git clone <your fork>
cd lisplings
./lisplings
With nix
The flake provides a pinned SBCL, a dev shell, and the lisplings runner. The nix store is read-only, so create your own writable course directory first - the runner then operates on the directory it is started from:
nix run . -- init my-lisplings # copy the course out of the store
cd my-lisplings
nix run /path/to/lisplings # watch mode, on this directory
nix develop gives a shell with SBCL for working on lisplings itself.
The workflow
- Run
./lisplingsfrom the repository root (or your project copy). - Lisplings keeps one status screen on your terminal: the current exercise file, the output of its checks, the hints you revealed, a progress bar, and the keys that work right now.
- Edit that file in any editor and save. The exercise runs again and
the screen redraws; when every check passes it shows
Exercise done ✓and the matching solution to compare against. - Press
nfor the next exercise.
Keys in watch mode (each key is a line: type it, then press ENTER):
| key | action |
|---|---|
| n | move to the next pending exercise |
| h | show the hint, pinned on the screen |
| r | rerun the current exercise |
| l | list all exercises |
| q | save progress and quit |
Keys typed while a check is running are ignored; press the key again once it finishes.
Really stuck? solutions/ mirrors exercises/ with every exercise
solved.
Commands
./lisplings watch the current exercise (the default)
./lisplings run [name] run one exercise and print its output
./lisplings hint [name] show the hint for an exercise
./lisplings list [pending|done|all]
./lisplings reset <name> restore an exercise to its pristine state
./lisplings check-all run every exercise and resync progress
./lisplings init [dir] create a lisplings project in dir
./lisplings help show all commands
Progress lives in .lisplings-state.sexp - a plain s-expression you can
read and edit. reset restores from a pristine snapshot taken under
.lisplings-orig/ the first time lisplings ran there, so start lisplings
before editing anything.
How an exercise works
Every exercise is a plain file of Common Lisp with the broken part marked TODO, and a checks section at the bottom:
;; TODO: Return twice the argument.
(defun twice (x)
x)
;;; Checks. Read them - they tell you what to aim for - but leave
;;; them unchanged.
(check-equal 10 (twice 5))
The checks are ordinary macros, defined in src/harness.lisp: check
asserts a non-NIL value, check-equal compares with EQUAL, and
check-error waits for a condition. Nothing is hidden - the tests
live in the same file you edit, which is the Lispy way.
The course
70 exercises in 20 chapters, from first forms to restarts, macros, and a tiny Lisp interpreter:
00_intro 01_sexps 02_functions 03_variables
04_conditionals 05_predicates 06_lists 07_recursion
08_functional 09_strings 10_loops 11_numbers
12_structs 13_hash_tables 14_packages 15_clos
16_conditions 17_macros 18_dynamic quizzes
Each chapter directory has a README with a two-line summary of the
ideas, and every exercise has a hint (h) and a solved twin under
solutions/.
Hacking on lisplings
Lisplings itself is a few hundred lines of SBCL with no dependencies:
the watcher (src/main.lisp, src/core.lisp), the check harness every
exercise runs under (src/harness.lisp), and the subprocess that
runs one exercise (src/exercise-runner.lisp).
dev/verify.sh # every exercise fails when broken, passes when solved
To add an exercise: write the broken exercises/<chapter>/<name>.lisp
and the solved solutions/<chapter>/<name>.lisp, add a (:name ... :dir ... :hint ...) entry to info.sexp, and run dev/verify.sh.