Luce by example
Complete programs, one idea at a time. Each one was compiled and run when this page was built, and the output shown under it is what it printed — on the compiled path and on the interpreter, which have to agree.
Copy any of them into a file and run loom luce thatfile.luc.
If you want the ideas explained rather than shown, read the tour instead; if you want the exact rules, read the reference.
Hello and argumentsThe smallest program, and reading the command line.
Loops and rangesrange, for over a collection, enumerate, while, break and continue.
ListsBuilding, sorting, searching, slicing.
MapsInsertion-ordered dictionaries with O(1) lookup.
Arrays and gridsFixed-shape numeric storage, up to four dimensions.
Text processingSplitting, joining, trimming and counting with std.strings.
StructsValue aggregates, namespaced functions, and structs that carry objects.
give, copy and freeThe four situations where memory needs a word from you.
Optionalsparse_int, none, narrowing, and the else fallback.
ErrorsA fallible function, try, catch, and an uncaught error's one-line report.
TrapsWhat a bug looks like: a stable code, a line, and a call trace.
FilesReading and writing through std.files, with the failure handled.
The bundled programsThe real userland in the repository, compiled and run from its own source.