/* Guess the number (Rosetta code) in Picat. http://rosettacode.org/wiki/Guess_the_number """ Write a program where the program chooses a number between 1 and 10. A player is then prompted to enter a guess. If the player guesses wrong, then the prompt appears again until the guess is correct. When the player has made a successful guess the computer will issue a "Well guessed!" message, and the program exits. A conditional loop may be used to repeat the guessing until the user is correct. """ This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ main => go. go => N = random(1,10), do print("Guess a number: ") while (read_int() != N), println("Well guessed!"). % {{trans|Prolog}} go2 => N = random(1, 10), repeat, print('Guess the number: '), N = read_int(), println("Well guessed!"), !.