More BASIC

Not that anybody should care, but I've reimplemented by BASIC.

Here's a simple program.

{-# LANGUAGE ExtendedDefaultRules, OverloadedStrings #-} import BASIC main = runBASIC $ do 10 GOSUB 1000 20 PRINT "* Welcome to HiLo *" 30 GOSUB 1000 100 LET I := INT(100 * RND(0)) 200 PRINT "Guess my number:" 210 INPUT X 220 LET S := SGN(I-X) 230 IF S <> 0 THEN 300 240 FOR X := 1 TO 5 250 PRINT X*X;" You won!" 260 NEXT X 270 STOP 300 IF S <> 1 THEN 400 310 PRINT "Your guess ";X;" is too low." 320 GOTO 200 400 PRINT "Your guess ";X;" is too high." 410 GOTO 200 1000 PRINT "*******************" 1010 RETURN 9999 END

In some ways this is a step backwards, since it requires some language extensions in Main. But I wanted to be able to use semicolon in the print statement.

But there it is, an exciting game!

******************* * Welcome to HiLo * ******************* Guess my number: 50 Your guess 50 is too high. Guess my number: 25 Your guess 25 is too low. Guess my number: 37 Your guess 37 is too low. Guess my number: 44 Your guess 44 is too low. Guess my number: 47 Your guess 47 is too low. Guess my number: 48 1 You won! 4 You won! 9 You won! 16 You won! 25 You won!

Labels: BASIC, DSL, Haskell