aboutsummaryrefslogtreecommitdiff
path: root/mathslap-rec
diff options
context:
space:
mode:
authorLarry Heyl <hairylarry@gmail.com>2026-07-30 02:32:05 +0000
committerLarry Heyl <hairylarry@gmail.com>2026-07-30 02:32:05 +0000
commit99ed9e86fe5aeeceba43ae45034ee6ac83a75921 (patch)
treef900f30432850af64b44b6780352bbe2cbf781a7 /mathslap-rec
parentbdc4c2e9234e08fe7a00bc83bd7c3683f6205655 (diff)
Recursive version of mathslap.
Diffstat (limited to 'mathslap-rec')
-rw-r--r--mathslap-rec/mathslap-rec.clisp34
1 files changed, 34 insertions, 0 deletions
diff --git a/mathslap-rec/mathslap-rec.clisp b/mathslap-rec/mathslap-rec.clisp
new file mode 100644
index 0000000..c09e3c2
--- /dev/null
+++ b/mathslap-rec/mathslap-rec.clisp
@@ -0,0 +1,34 @@
+;;;; MathSlap program written by Larry Heyl - Game developed by Carl Heyl
+;;;; To win make an equation with the supplied numbers, in order, adding any symbols you want but one and only one equal sign.
+;;;; This version uses a recursive loop instead of LOOP.
+
+;;;; concise instructions
+(print "MathSlap")
+(print "Hit Enter for another number. q and Enter to quit.")
+
+(defparameter *line* "")
+(defparameter *out* "MathSlap ")
+(defparameter *random-state* 0)
+(setq *random-state* (make-random-state t))
+
+;;;; append string parameter with a random number 1 through 10 and a space
+(defun concat (o)
+ (concatenate 'string o (write-to-string (+ (random 10) 1)) " ")
+)
+
+(defun recloop (o)
+;;;; append o with a random number 1 through 10 and a space
+ (setq o (concat o))
+ (print o)
+;;;; wait for input
+ (setq *line* (read-line *standard-input*))
+ (if (string= *line* "q")(quit))
+ (recloop o)
+)
+
+;;;; Add numbers to output string. Comment one of these out to start with 2 numbers.
+(setq *out* (concat *out*))
+(setq *out* (concat *out*))
+;;;; recursive loop
+(recloop *out*)
+