aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGene Pasquet <dev@etenil.net>2026-07-30 20:37:17 +0100
committerGene Pasquet <dev@etenil.net>2026-07-30 20:37:17 +0100
commit86d7aafea65e8048c56bdf5c81bf9c7a7f095022 (patch)
tree73a4740af0a8680fe2cde2d4f105ff9f7418d9c7
parente426b6afac91ba4088d0023127e5f65fad943414 (diff)
Add conditional start so code can be loaded in replHEADmain
-rw-r--r--mathslap-rec/mathslap-rec.clisp19
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))