From: Marco Baringer Date: Fri, 20 Jan 2006 17:26:25 +0000 (+0100) Subject: Added :alphanumericp keyword to gen-character X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=576bc9b8fee8387b173cc728b6e22321c82413ed;p=fiveam.git Added :alphanumericp keyword to gen-character --- diff --git a/src/random.lisp b/src/random.lisp index 0f66f84..6cf070d 100644 --- a/src/random.lisp +++ b/src/random.lisp @@ -120,8 +120,14 @@ returning true. This second run limit prevents that.") (min (1+ most-negative-fixnum))) (+ min (random (1+ (- max min))))) -(defgenerator gen-character (&key (code (gen-integer :min 0 :max (1- char-code-limit)))) - (code-char (funcall code))) +(defgenerator gen-character (&key (code (gen-integer :min 0 :max (1- char-code-limit))) + (alphanumericp nil)) + (if alphanumericp + (code-char (funcall code)) + (loop + for char = (code-char (funcall code)) + until (alphanumericp char) + finally (return char)))) (defun gen-string (&key (length (gen-integer :min 0 :max 80))