Examples
Runnable Crush programs. Every program and every output block on these pages is
executed against crush-ast dc0d0278 by scripts/check-examples.py, so what you
read is what happens. Pages also record where a
language feature is not yet implemented, with the crush-ast ticket.
| Example | Pattern | Flags to run it |
|---|---|---|
| Fibonacci & Functions | Recursion, typed signatures | — |
| Arrays & Loops | Arrays, for, break/continue, FizzBuzz | — |
| Exception Handling | try/catch/throw | — |
| Structs (and Concurrency) | Structs with methods; spawn/await | — |
| Lambdas & Pipes | |> pipelines, lambdas, closures | — |
| Import Styles | Every import form, and why none loads yet | — |
| System Info Report | env.*, time.* capabilities | --env --time |
| Build Pipeline | process.exec, fail-fast steps | --process |
| Polyglot Pipeline | Python + JavaScript + Bash in one program | --polyglot |
| Showcase: awesome-crush | Games, interpreters and an agent tool written by LLMs | varies |
The verified corpus has 120+ more, one small program per behaviour, each with its exact output.
Run any of them with crush run [flags] file.crush (see
Getting Started).