You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
504 B

(in-package #:cl-rng)
(defun crandom (&key (limit 1.0) (precision 1) (transform nil))
(let ((transform (or transform #'identity)))
(multiple-value-bind (result ok) (cl-rng-ffi:ffi-sample)
(and ok
(funcall transform
(* limit
(if (< precision 2)
result
(/ (apply #'+ (mapcan #'(lambda (x)
(and (not (null x))
(list x)))
(loop for x from 0 below precision collect
(crandom))))
precision))))))))
(export 'crandom)