style: auto-format example files with lux fmt

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-17 06:52:44 -05:00
parent 8c90d5a8dc
commit 44ea1eebb0
54 changed files with 580 additions and 1483 deletions

View File

@@ -1,36 +1,19 @@
// Demonstrating behavioral properties in Lux
// Behavioral properties are compile-time guarantees about function behavior
//
// Expected output:
// add(5, 3) = 8
// factorial(5) = 120
// multiply(7, 6) = 42
// abs(-5) = 5
fn add(a: Int, b: Int): Int is pure = a + b
// A pure function - no side effects, same input always gives same output
fn add(a: Int, b: Int): Int is pure =
a + b
fn factorial(n: Int): Int is deterministic = if n <= 1 then 1 else n * factorial(n - 1)
// A deterministic function - same input always gives same output
fn factorial(n: Int): Int is deterministic =
if n <= 1 then 1
else n * factorial(n - 1)
fn multiply(a: Int, b: Int): Int is commutative = a * b
// A commutative function - order of arguments doesn't matter
fn multiply(a: Int, b: Int): Int is commutative =
a * b
fn abs(x: Int): Int is idempotent = if x < 0 then 0 - x else x
// An idempotent function - absolute value
fn abs(x: Int): Int is idempotent =
if x < 0 then 0 - x else x
// Test the functions
let sumResult = add(5, 3)
let factResult = factorial(5)
let productResult = multiply(7, 6)
let absResult = abs(0 - 5)
// Print results
fn printResults(): Unit with {Console} = {
Console.print("add(5, 3) = " + toString(sumResult))
Console.print("factorial(5) = " + toString(factResult))