Created
January 2, 2014 14:47
-
-
Save ponkore/8220249 to your computer and use it in GitHub Desktop.
clojure.core の関数の doc-string をランダムに表示 (random-docs)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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