Adedd gen-one-element
authorMarco Baringer <mb@bese.it>
Sat, 8 Apr 2006 10:00:22 +0000 (12:00 +0200)
committerMarco Baringer <mb@bese.it>
Sat, 8 Apr 2006 10:00:22 +0000 (12:00 +0200)
src/packages.lisp
src/random.lisp

index 7828de5..131dfd5 100644 (file)
@@ -51,6 +51,7 @@
            #:gen-string
            #:gen-list
            #:gen-buffer
+           #:gen-one-element
           ;; running tests
            #:run
            #:run-all-tests
index e869a1c..ba0abf8 100644 (file)
@@ -241,5 +241,9 @@ producs objects."
     (let ((buffer (make-array (funcall length) :element-type element-type)))
       (map-into buffer elements))))
 
+(defun gen-one-element (&rest elements)
+  (lambda ()
+    (nth (random (length elements)) elements)))
+
 ;;;; The trivial always-produce-the-same-thing generator is done using
 ;;;; cl:constantly.