From 25b02b6e536197f46c8951fed21a452340328bb9 Mon Sep 17 00:00:00 2001 From: Marco Baringer Date: Sat, 8 Apr 2006 12:00:22 +0200 Subject: [PATCH] Adedd gen-one-element --- src/packages.lisp | 1 + src/random.lisp | 4 ++++ 2 files changed, 5 insertions(+) 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. -- 1.7.10.4