From: Marco Baringer Date: Sat, 8 Apr 2006 10:00:22 +0000 (+0200) Subject: Adedd gen-one-element X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=25b02b6e536197f46c8951fed21a452340328bb9;p=fiveam.git Adedd gen-one-element --- diff --git a/src/packages.lisp b/src/packages.lisp index 7828de5..131dfd5 100644 --- a/src/packages.lisp +++ b/src/packages.lisp @@ -51,6 +51,7 @@ #:gen-string #:gen-list #:gen-buffer + #:gen-one-element ;; running tests #:run #:run-all-tests diff --git a/src/random.lisp b/src/random.lisp index e869a1c..ba0abf8 100644 --- a/src/random.lisp +++ b/src/random.lisp @@ -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.