Files
lux/examples/standard/fizzbuzz.lux
Brandon Lucas 0b5abece5f feat: add comprehensive example programs
Standard examples (examples/standard/):
- hello_world: Basic effect usage
- fizzbuzz: Classic programming exercise
- factorial: Recursive and tail-recursive versions
- primes: Prime number generation
- guessing_game: Interactive Random + Console effects
- stdlib_demo: Demonstrates List, String, Option, Math modules

Showcase examples (examples/showcase/):
- ask_pattern: Resumable effects for config/environment
- custom_logging: Custom effect with handler
- early_return: Fail effect for clean error handling
- effect_composition: Combining multiple effects
- higher_order: Closures and function composition
- pattern_matching: ADTs and exhaustive matching

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-13 17:25:04 -05:00

23 lines
567 B
Plaintext

// FizzBuzz - print numbers 1-100, but:
// - multiples of 3: print "Fizz"
// - multiples of 5: print "Buzz"
// - multiples of both: print "FizzBuzz"
fn fizzbuzz(n: Int): String =
if n % 15 == 0 then "FizzBuzz"
else if n % 3 == 0 then "Fizz"
else if n % 5 == 0 then "Buzz"
else toString(n)
fn printFizzbuzz(i: Int, max: Int): Unit with {Console} =
if i > max then ()
else {
Console.print(fizzbuzz(i))
printFizzbuzz(i + 1, max)
}
fn main(): Unit with {Console} =
printFizzbuzz(1, 100)
let output = run main() with {}