Example programs

These aren't written for this documentation - they're the actual programs in tests/programs, which the interpreter's own snapshot test suite (python -m src.Main test, see the CLI reference) runs against on every change. Reading them is a good way to see idiomatic Falx at a slightly larger scale than the tutorials.

Bank account manager View source

Closures used as private-state "objects" - deposit, withdraw and a running transaction log, all without a single struct.

closuresfunctions
Shopping cart & discounts View source

A cart built from closures, with a configurable discount calculator and item totals.

closuresarrays
Inventory management View source

Structs for products, a map keyed by SKU, and the keys()-plus-indexing pattern for iterating key/value pairs.

structsmapsarrays
Player module (two files) View source

The smallest possible require() example - a struct defined in player.flx and used from main.flx. See it walked through in the structs-and-modules tutorial.

modulesstructs

Also see players/player.flx

Task scheduler View source

A Task struct plus a closure-based scheduler that adds, completes and filters tasks by priority.

structsclosuresarrays
Text analyzer View source

Word-frequency counting over a block of text, using a WordStat struct and string methods like split() and toLower().

structsstringsarrays
Statistical analyzer View source

Small numeric helpers - weighted averages, score normalization - chained together.

functionsnumbers
System monitor View source

The single most comprehensive example in the test suite: structs, maps, arrays, null checks, loops and closures combined in one program.

structsmapsarraysclosures
Calculator engine View source

The same four arithmetic operations as the calculator tutorial, plus a createScaledOp() closure that wraps any operation with a scale factor.

functionsclosures
Closure factory View source

A short, ten-line demonstration of one function returning several independently-configured closures.

closures
String formatter pipeline View source

Composable prefix/suffix closures chained into a small text-formatting pipeline.

closuresstrings
String concatenation loop View source

A six-line micro-example of building a string with + inside a while loop.

whilestrings
Each example has a matching .out file next to it in the repository with the exact expected output - a quick way to check your own local interpreter build behaves the same way.