// Number guessing game - demonstrates Random and Console effects fn gameLoop(secret: Int, attempts: Int): Unit with {Console} = { Console.print("Guess the number (1-100), attempt " + toString(attempts) + ":") let guess = Console.readInt() if guess == secret then Console.print("Correct! You got it in " + toString(attempts) + " attempts!") else if guess < secret then { Console.print("Too low!") gameLoop(secret, attempts + 1) } else { Console.print("Too high!") gameLoop(secret, attempts + 1) } } fn main(): Unit with {Console, Random} = { Console.print("Welcome to the Guessing Game!") Console.print("I'm thinking of a number between 1 and 100...") let secret = Random.int(1, 100) gameLoop(secret, 1) } let output = run main() with {}