【发布时间】:2019-12-21 17:13:55
【问题描述】:
我需要生成一个随机字符并构建一个字符串,并且仅在我的字符串包含新生成的字符时才停止。
(defn rand-char [len]
(apply str (take len (repeatedly #(char (+ (rand 26) 65))))))
(def random-string
(loop [x (rand-char 1)
result []]
(if (some #(= x %) result)
(apply str (conj result x))
(recur (conj result x) (x (rand-char 1))))))
我来了
java.lang.String cannot be cast to clojure.lang.IFn
【问题讨论】: