Every example carries its exact run command in a header comment. The
directory tells you which dialect it needs: x/ runs on the default dialect (helium), xe/
needs -l xe (xenon), rn/ needs -l rn (radon).
Every example is executed in CI (make check-examples, part of make test),
with output pinned where it is portable — so the run commands and outputs you
see here are verified, not aspirational.
Read them in this order.
x/)No flags needed — these run on the default dialect.
| File | Lines | What it shows |
|---|---|---|
x/hello.x |
7 | Output: display and newline. Start here. |
x/lists.x |
32 | Pairs, list construction, and the higher-order functions (map, filter, fold) |
x/factorial.x |
31 | Self-as-argument-0 — recursion without a global name — plus a tail-recursive accumulator and a note on where 64-bit integers run out |
x/fibonacci.x |
27 | Recursion and iteration compared |
sh x.sh -f examples/x/hello.x
x/factorial.x is the one to read closely if you only read one: it explains
why every closure receives itself as its first argument, which is the piece of
x-lang that surprises people coming from Scheme.
xe/)Needs -l xe (xenon), which adds the numeric tower, POSIX, hash tables, and the
JIT.
| File | Lines | What it shows |
|---|---|---|
xe/numeric-tower.x |
29 | Automatic promotion across integers, bigints, rationals, floats, and complex numbers |
xe/regex.x |
25 | The #/pattern/ literal, and a regex used as a callable value |
sh x.sh -l xe -f examples/xe/numeric-tower.x
rn/)Needs -l rn (radon). This dialect is explicitly experimental; it adds the raw
syscall surface (file I/O loads on demand — see rn/cat.x). These examples
touch the operating system directly.
| File | Lines | What it shows |
|---|---|---|
rn/hello.x |
10 | Output via a raw write syscall instead of the library |
rn/cat.x |
22 | Reading a file with raw syscalls (note the working-directory caveat in its header) |
rn/execve-ls.x |
16 | fork + execve to run /bin/ls |
sh x.sh -l rn -f examples/rn/hello.x
There is no example of one here any more, and where it went is the point.
Logo — ~2,400 lines of x-lang implementing its own tokenizer, an infix
expression parser, an HTTP server and a live SVG turtle — used to live in this
repository as apps/logo/, with the Chapter-1 turtle programs from Turtle
Geometry (Abelson & diSessa, 1981) beside it as logo/ch1.logo.
It is now x-logo, acquired rather than bundled with the platform, and the example went with it:
x --install-lang https://github.com/jonruttan/x-logo/releases/latest/download/lang.pin.xon
x -l logo # REPL + live turtle at http://localhost:8080
The examples in this directory are all x-lang. A lang’s examples belong to the lang, for the same reason its specs do — see the lang contract.
Two of the language’s headline features have no example here. Until they do, the references are:
op — user-level operatives that receive their arguments
unevaluated along with the caller’s environment. See
The Fexpr Model and
docs/spec.md.def-class — see
docs/object-system.md.