I've just started learning Clojure, if I define the following map:
(def distributions {:normal {:title "Normal" :mean 0 :sd 1}
:beta {:title "Beta" :a 1 :b 3}
:gamma {:title "Gamma" :rate 1/2 :shap开发者_JAVA百科e 1}})
how would I write (defn get-titles [] ...)
a function that would return
("Normal", "Beta", "Gamma")
?
(defn get-titles [] (map :title (vals distributions)))
Alternatively: (for [[k v] distr] (:title v))
精彩评论