RosettaCodeData/Task/Pick-random-element/Emacs-Lisp/pick-random-element.l

8 lines
158 B
Text
Raw Permalink Normal View History

2019-09-12 10:33:56 -07:00
(defun random-choice (items)
(let* ((size (length items))
(index (random size)))
(nth index items)))
(random-choice '("a" "b" "c"))
;; => "a"