Skip to content
This repository has been archived by the owner on Aug 15, 2022. It is now read-only.

Commit

Permalink
Random list element.
Browse files Browse the repository at this point in the history
  • Loading branch information
dardoria committed Mar 1, 2012
1 parent 4555f0c commit 1c3ad3d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.lisp
Expand Up @@ -101,4 +101,5 @@
#:make-curve
;;utils
#:radian
#:random-range))
#:random-range
#:random-element))
5 changes: 4 additions & 1 deletion utils.lisp
Expand Up @@ -36,4 +36,7 @@
(let ((range (- y x)))
(when (rationalp range)
(setf range (coerce range 'float)))
(+ x (random range ))))))
(+ x (random range ))))))

(defun random-element (sequence)
(nth (random (length sequence)) sequence))

0 comments on commit 1c3ad3d

Please sign in to comment.