Rail Examples
Twenty-two programs, each with its source and captured output. Pick one and read the source: that is the fastest way to learn Rail.
- calculator — expression evaluator with ADTs —
calculator - closures — lambdas and higher-order functions —
closures - concurrency — fibers and channels —
concurrency - error_test — what a Rail error looks like —
error_test - fibonacci — recursion, range, map —
fibonacci - file_processor — read, write, transform files —
file_processor - fizzbuzz — the classic interview question —
fizzbuzz - hello — first Rail program —
hello - lists — cons, map, fold, filter, range —
lists - pattern_matching — ADTs and `match` —
pattern_matching - pipes — the `|>` operator —
pipes - quicksort — functional quicksort on lists —
quicksort - string_processing — split, join, reverse, append, shell —
string_processing - tco_test — tail call optimization —
tco_test - wasm/adt — ADTs and pattern matching in WebAssembly —
wasm_adt - wasm/closure — captured locals in WASM —
wasm_closure - wasm/fib — recursive Fibonacci in WebAssembly —
wasm_fib - wasm/hello — Rail to WebAssembly —
wasm_hello - wasm/loop — GC stress test in 1 MB heap —
wasm_loop