Last active
November 23, 2022 15:15
-
-
Save CarnunMP/c592cd3b6e711d56ddd4ca7832b9b251 to your computer and use it in GitHub Desktop.
tiny babashka script that returns a random clojure doc
This file contains 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
#!/usr/bin/env bb | |
(require '[clojure.repl]) | |
(def namespaces ; well, readily available ones | |
['clojure.core | |
'clojure.edn | |
'clojure.instant | |
'clojure.java.browse | |
'clojure.java.io | |
'clojure.java.shell | |
'clojure.main | |
'clojure.pprint | |
'clojure.repl | |
'clojure.string | |
'clojure.walk]) | |
(defmacro random-doc [] | |
(let [sym (->> namespaces | |
(mapcat ns-publics) | |
(filter (comp :doc meta resolve first)) | |
rand-nth | |
first)] | |
`(clojure.repl/doc ~sym))) | |
(random-doc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
inspired by https://github.com/tomekw/cotd :)