Skip to content
kata / a language workbench

Examples

Each example starts from a standalone .ks source file and a sibling .expected file in site/examples/. Its original expected output is checked against the interpreter. Edit the source and choose Run to produce live output, or Debug to inspect statement checkpoints and bindings. Click a recognized token for contextual help.

ExampleWhat it exercises
FibonacciInteger arithmetic, loop state, typed functions
Word frequencyString transformations, arrays, maps, optional lookup
Closure counterFunction values, captured state, independent factory calls
Result pipelineInput contracts, Res, propagation, pattern matching
Custom iteratorKinds, interfaces, mutable iterator state, for

Run directly in an example’s editor, or use the playground for a separate experiment. The playground guide explains stepping, stopping, resetting, and the execution budget.

From the repository root:

Terminal window
cargo run -- ks site/examples/fibonacci.ks

To compare its output yourself after building:

Terminal window
target/debug/kata ks site/examples/fibonacci.ks > /tmp/fibonacci.actual
diff -u site/examples/fibonacci.expected /tmp/fibonacci.actual

No output from diff means the text matches. If you modify a script, reason through the new output before changing its expected file.

These examples are small enough to inspect completely. They deliberately keep collection growth on direct bindings, avoid custom resource ownership, and use bounded computations. Read language status before generalizing them into larger programs.