Skip to main content

Worked examples

Each example below is a complete, runnable .esq program. Save it, compile it with ./esquec build foo.esq -o foo, run it. Each page explains what the program does, the language ideas it exercises, and how to read the generated code if you are curious.

The examples are roughly ordered by complexity:

#PageIdea
1Exit statusshortest possible programs; arithmetic
2Recursionself-recursive functions, conditionals
3Dot productshape-generic tensor function
4Euclidean distancecomposing tensor ops
5Scan / prefix sumrunning accumulators
6Iterate untilbounded fixpoint

Every fixture also lives under tests/e2e/ in the repo, where it has an associated test that asserts on the exit code and (where relevant) stdout.