Skip to content

Instantly share code, notes, and snippets.

@ponkore
Created January 2, 2014 14:47
Show Gist options
  • Save ponkore/8220249 to your computer and use it in GitHub Desktop.
Save ponkore/8220249 to your computer and use it in GitHub Desktop.
clojure.core の関数の doc-string をランダムに表示 (random-docs)
(defn get-doc-string
[ns sym]
(let [wrt (java.io.StringWriter.)]
(binding [*out* wrt]
(->> (ns-resolve ns sym)
(meta)
(#'clojure.repl/print-doc)))
(.toString wrt)))
(def syms (-> 'clojure.core ns-map keys sort))
(def clojure-core-docs (->> syms (map #(get-doc-string 'clojure.core %))))
(defn random-docs
[]
(println (rand-nth clojure-core-docs)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment