| example | what it shows |
[calc.tr](../examples/calc.tr) | A recursive data type: a tiny expression language with an evaluator and simplifier. |
[collections.tr](../examples/collections.tr) | Maps and sets: value semantics (a copy never changes behind your back), updated in place |
[hello.tr](../examples/hello.tr) | No type annotations anywhere: every type below is inferred. |
[records.tr](../examples/records.tr) | Records: constructors with named fields. Read with .field, copy-with-changes with .with(...). |
| example | what it shows |
[fstrings.tr](../examples/fstrings.tr) | f-strings and characters. |
[json.tr](../examples/json.tr) | A JSON parser and printer: recursive-descent, mutually recursive types, error positions. |
[json_library.tr](../examples/json_library.tr) | The JSON library (M2): parse_json, to_json, to_json_pretty and the json_* accessors, in every |
[text.tr](../examples/text.tr) | Text basics: parsing numbers, trimming, prefixes, fixed-decimal formatting. |
[time_library.tr](../examples/time_library.tr) | The time library (M2): timestamps (seconds since 1970, as now(sys) gives) as dates, formatted |
| example | what it shows |
[fbip.tr](../examples/fbip.tr) | Functional but in-place: code that rebuilds a uniquely owned tree reuses the tree's own memory. |
[kernels.tr](../examples/kernels.tr) | Pure array kernels: grid builds a matrix element by element, sum reduces in order. |
[matmul.tr](../examples/matmul.tr) | Matrix multiply: the future home of the first schedule demo |
[sorting.tr](../examples/sorting.tr) | Sorting: sort orders a list, sort_by orders it by a key, reverse turns it around. |
| example | what it shows |
[async.tr](../examples/async.tr) | async functions and par_map over records and closures (M4) |
[tasks.tr](../examples/tasks.tr) | Scoped tasks: spawn(fn() => ...) runs work alongside the rest of the function; wait(t) |
[tools/fetch.tr](../examples/tools/fetch.tr) | An HTTP fetcher (M2): get a URL, show the status, and pretty-print JSON or pick a field. |
[tools/fetch_all.tr](../examples/tools/fetch_all.tr) | Fetch many URLs at once (M4): each fetch is an async task, so they all wait on the network |
| example | what it shows |
[generators_basics.tr](../examples/generators_basics.tr) | Generators: a function that yields values one at a time, consumed by a for loop as they come. |
[generators_more.tr](../examples/generators_more.tr) | generator values, parameters, maps and strings in loop bodies, early returns from inlined loops |
[generators_tree.tr](../examples/generators_tree.tr) | A recursive generator: walking a binary tree in order, without building a list. |
| example | what it shows |
[comprehensions.tr](../examples/comprehensions.tr) | M1 conveniences: comprehensions, updates like +=, nested index assignment, repetition, |
[ffi.tr](../examples/ffi.tr) | C math from Trine: extern fn declares a libm function on numbers (no permission needed for pure math). |
[higher_order.tr](../examples/higher_order.tr) | Generic functions with zero annotations: map/filter/fold are inferred polymorphic |
[immediates.tr](../examples/immediates.tr) | Small values without allocation: Ints, Bools and nullary constructors are immediates, and Option of them is cheap. |
[lists.tr](../examples/lists.tr) | Lists of every element kind. Natively, each kind uses its own storage (raw int64, raw double, |
[loops.tr](../examples/loops.tr) | break and continue: leave a loop early, or skip to its next round. |
[primes.tr](../examples/primes.tr) | Sieve of Eratosthenes with in-place list updates (unique owner => no copies). |
[raytrace.tr](../examples/raytrace.tr) | An ASCII ray tracer: spheres, diffuse lighting, hard shadows. Floats + data types + loops. |
[server.tr](../examples/server.tr) | An HTTP-style request handler for a todo service. Raw requests are parsed, routed, |
[shapes.tr](../examples/shapes.tr) | Algebraic data types + exhaustive pattern matching. |
[slices.tr](../examples/slices.tr) | Slices and string functions: take part of a list or a string, search, replace, change case. |
[values.tr](../examples/values.tr) | Mutable value semantics: no aliasing surprises, no lifetimes. |