random vector and list work the same

master
Avril 5 years ago
parent 2434170e50
commit a1a21ce212
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -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))))

Loading…
Cancel
Save