From a1a21ce21220f12ffcf3b11c7388c46a3ad4146d Mon Sep 17 00:00:00 2001 From: Avril Date: Sun, 19 Apr 2020 03:01:46 +0100 Subject: [PATCH] random vector and list work the same --- cl-rng.lisp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cl-rng.lisp b/cl-rng.lisp index 93d2323..7b063ae 100644 --- a/cl-rng.lisp +++ b/cl-rng.lisp @@ -20,7 +20,7 @@ (defun %urandom-list (range &rest params) (setf (car range) (apply 'urandom params)) (when (not (null (cdr range))) - (apply '%urandom-list (cons (cdr range) params)))) + (cons (car range) (apply '%urandom-list (cons (cdr range) params))))) (defun urandom-range (range &rest params) (if (listp range) @@ -30,3 +30,19 @@ (export 'urandom) (export 'urandom-range) +;(defparameter *dice-results* (make-list 10)) + + +; (let ((num 0) +; (max 10000) +; (low 50)) +; (format t "~%Searching ~a values for >= ~a...~%" max low) +; (loop for i from 0 below max do +; (let ((value (apply '+ (urandom-range *dice-results* :limit 6 :transform (lambda (x) (1+ (floor x))))))) +; (and (>= value low) +; (incf num) +; (format t " -> ~a: ~a~%" i value)))) +; (format t "Found ~a / ~a (~,8f %)~%" num max (* 100 (/ num max)))) + + +