Commits

Robert Smith committed f722005

* Add RANDOM-ELT. Incomplete.

Comments (0)

Files changed (2)

qtility-package.lisp

    ;; random.lisp
    #:reseed-random-state
    #:random-between
+   #:random-elt
    #:nshuffle-vector
    #:shuffle
    
       a
       (+ a (random (- (1+ b) a)))))
 
+(defun random-elt (seq &optional distribution)
+  "Choose a random element of SEQ according to DISTRIBUTION. If
+DISTRIBUTION is null, the distribution will be uniform. Otherwise,
+<stub>."
+  (if (null distribution)
+      (elt seq (random-between 0 (1- (length seq))))
+      (stub 'random-elt)))
+
 (defun nshuffle-vector (vector)
   "Destructively shuffle VECTOR randomly."
   (let ((n (length vector)))