Random Choice From List Of Strings In Emacs Lisp

[Solved] Random Choice From List Of Strings In Emacs Lisp | Lisp - Code Explorer | yomemimo.com
Question : random choice from list of strings in emacs lisp

Answered by : nopanun-laochunhanun

;; Emacs Lisp
(defun random-choice (items) (nth (random (length items)) items))
(random-choice '("a" "b" "c"))
;; => "a"

Source : https://www.rosettacode.org/wiki/Pick_random_element#Emacs_Lisp | Last Update : Fri, 06 May 22

Answers related to random choice from list of strings in emacs lisp

Code Explorer Popular Question For Lisp