1 USING: combinators io kernel math.order math.parser random ;
5 "I'm thinking of a number between 0 and 100." print flush ;
7 : guess-number ( -- n )
8 "Enter your guess: " write flush readln string>number ;
10 : correct? ( actual guess -- ? )
12 { +lt+ [ "Too high" print flush f ] }
13 { +eq+ [ "Correct - you win!" print flush t ] }
14 { +gt+ [ "Too low" print flush f ] }
17 : numbers-game-loop ( actual -- )
18 [ dup guess-number correct? not ] loop drop ;
21 guess-banner 100 random numbers-game-loop ;