如果我有一个列表:
["apples" "pears" "oranges"]
从这里获取随机物品的最简单方法是什么?
答案 0 :(得分:10)
rand-nth应该这样做:
user> (rand-nth ["apples" "pears" "oranges"])
"pears"
user> (rand-nth ["apples" "pears" "oranges"])
"oranges"
user> (rand-nth ["apples" "pears" "oranges"])
"oranges"