diff options
Diffstat (limited to 'mathslap-rec/mathslap-rec.clisp')
| -rw-r--r-- | mathslap-rec/mathslap-rec.clisp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/mathslap-rec/mathslap-rec.clisp b/mathslap-rec/mathslap-rec.clisp index 86d607b..121d62d 100644 --- a/mathslap-rec/mathslap-rec.clisp +++ b/mathslap-rec/mathslap-rec.clisp @@ -3,9 +3,6 @@ ;;;; This version uses a recursive loop instead of LOOP. ;;;; concise instructions -(print "MathSlap") -(print "Hit Enter for another number. q and Enter to quit.") - (setq *random-state* (make-random-state t)) ;;;; Generate a random number for our game. Avoid having to write the @@ -36,6 +33,16 @@ ;;;; Initiate the recursion ;; Use a LET* form for local variables, with defined variables depending on each other. -(let* ((starting-numbers (list (have-number) (have-number))) - (starting-prompt (format nil "MathSlap ~{~a ~}" starting-numbers))) - (recloop starting-prompt nil)) + +(defun run-game () + (print "MathSlap") + (print "Hit Enter for another number. q and Enter to quit.") + + (let* ((starting-numbers (list (have-number) (have-number))) + (starting-prompt (format nil "MathSlap ~{~a ~}" starting-numbers))) + (recloop starting-prompt nil))) + + +;;;; Run the game right away when loaded as a script +(when (interactive-stream-p *standard-input*) + (run-game)) |
