spesk 9 months ago
parent
commit
b8bac1e3bf
1 changed files with 8 additions and 7 deletions
  1. 8 7
      spell.lisp

+ 8 - 7
spell.lisp

@@ -1,5 +1,7 @@
 ;;#!/usr/bin/sbcl --script
 
+(defvar *randomness* (make-random-state t))
+
 (defun split-string (string delimiter)
   (loop with len = (length string)
         with start = 0
@@ -26,18 +28,17 @@
 		       collect (format NIL "~a~c" path #\/)))))
 
 (defun random-bin (bins-list)
-  (nth (random (length bins-list)) bins-list))
+  (namestring (nth (random (length bins-list) *randomness*) bins-list)))
 
 (defun random-cmd (bins-list)
-  (let ((number-of-pipes (random 4))
+  (let ((number-of-pipes (random 4 *randomness*))
 	(cmd-str ""))
     (if (> number-of-pipes 0)
 	(progn
 	  (dotimes (i (+ 1 number-of-pipes))
-	    (setf cmd-str (concatenate 'string cmd-str (format NIL "~A | " (random-bin bins-list)))))
-	  (setf cmd-str (concatenate 'string (subseq cmd-str 0 (- (length cmd-str) 3)) (format NIL "~%"))))
-	(setf cmd-str (concatenate 'string cmd-str (format NIL "~A~%" (random-bin bins-list)))))
+	    (setq cmd-str (concatenate 'string cmd-str (format NIL "~A | " (random-bin bins-list)))))
+	  (setq cmd-str (concatenate 'string (subseq cmd-str 0 (- (length cmd-str) 3)) (format NIL "~%"))))
+	(setq cmd-str (concatenate 'string cmd-str (format NIL "~A~%" (random-bin bins-list)))))
     cmd-str))
   
-;; (format T "~A" (random-cmd (bins-list)))
-(format T "~A" (random-bin (bins-list)))
+(format T "~a" (random-cmd (bins-list)))