]> gitweb.factorcode.org Git - factor.git/commitdiff
number-game: need to flush the output
authorBjörn Lindqvist <bjourne@gmail.com>
Sun, 2 Jul 2017 22:13:06 +0000 (00:13 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Sun, 2 Jul 2017 22:13:06 +0000 (00:13 +0200)
extra/numbers-game/numbers-game.factor

index e0d00986fc23810d206f1e3620591934596ca1bd..6fae3d99c51b291f38eac2adff0842a323fb21ec 100644 (file)
@@ -1,14 +1,25 @@
 USING: kernel math math.parser random io ;
 IN: numbers-game
 
-: read-number ( -- n ) readln string>number ;
+: printfl ( s -- )
+    print flush ;
+
+: writefl ( s -- )
+    write flush ;
+
+: read-number ( -- n )
+    readln string>number ;
 
 : guess-banner ( -- )
-    "I'm thinking of a number between 0 and 100." print ;
-: guess-prompt ( -- ) "Enter your guess: " write ;
-: too-high ( -- ) "Too high" print ;
-: too-low ( -- ) "Too low" print ;
-: correct ( -- ) "Correct - you win!" print ;
+    "I'm thinking of a number between 0 and 100." printfl ;
+
+: guess-prompt ( -- ) "Enter your guess: " writefl ;
+
+: too-high ( -- ) "Too high" printfl ;
+
+: too-low ( -- ) "Too low" printfl ;
+
+: correct ( -- ) "Correct - you win!" printfl ;
 
 : inexact-guess ( actual guess -- )
      < [ too-high ] [ too-low ] if ;