PicoLisp Examples Examined
There are many PicoLisp example files and snippets around the internet. I believe one good way to learn a new language, and to see the patterns and idiomatic expressions the community uses, is to read and run real source code. That is what we do on the pages below.
What changed since I first wrote these studies
When I wrote these in 2017, the PicoLisp tarball had a misc/ folder full of demo programs: life.l, chat, crc.l, fibo.l and more. In today’s pil21 (I checked 26.9, October 2026), misc/ holds only the bigtest and stress.l test scripts. The demos are gone from the distribution. So each study page now contains a complete, working program that I re-tested on 26.9, along with my original walk-through.
The other big difference is namespaces. Some libraries (@lib/simul.l, @lib/ai.l) now define their own namespace, so old code that calls grid or disp straight after (load "@lib/simul.l") fails with grid -- Undefined. Add (symbols '(simul pico)) or write simul~grid.
The studies
- Life: Conway’s Game of Life on a
simul.lgrid. It shows properties as state,=:/:withThis, and namespaces. - Chat: a multi-user chat server in about 25 lines. It shows
port/listen/fork,tellfor inter-process messages, andtaskfor event handling. - The Health Application: a tiny database web app using
http.l,xhtml.landform.l.
Where to find more examples today
- The pil21 tarball itself:
lib/*.lis idiomatic code by the author,test/exercises nearly every built-in, and@lib/vip.lis a whole editor. - Rosetta Code, PicoLisp category: hundreds of tasks.
- PicoLisp by Example: the book form of the above (see PicoLisp By Example).
- picolisp.com wiki: articles and small apps by the community.
How I read an example
- Run it first, unchanged, and see what it does.
(pp 'fn)each function and guess what it does before reading the docs.- Look up anything unfamiliar with
(doc 'fn)inpil +. - Change one thing and run it again.
