// Demonstrating Random and Time effects in Lux // // Expected output (values will vary): // Rolling dice... // Die 1: // Die 2: // Die 3: // Coin flip: // Random float: <0.0-1.0> // Current time: // Roll a single die (1-6) fn rollDie(): Int with {Random} = Random.int(1, 6) // Roll multiple dice and print results fn rollDice(count: Int): Unit with {Random, Console} = { if count > 0 then { let value = rollDie() Console.print("Die " + toString(4 - count) + ": " + toString(value)) rollDice(count - 1) } else { () } } // Main function demonstrating random effects fn main(): Unit with {Random, Console, Time} = { Console.print("Rolling dice...") rollDice(3) let coin = Random.bool() Console.print("Coin flip: " + toString(coin)) let f = Random.float() Console.print("Random float: " + toString(f)) let now = Time.now() Console.print("Current time: " + toString(now)) } let output = run main() with {}