Skip to content

Instantly share code, notes, and snippets.

@CarnunMP
Last active November 23, 2022 15:15
Show Gist options
  • Save CarnunMP/c592cd3b6e711d56ddd4ca7832b9b251 to your computer and use it in GitHub Desktop.
Save CarnunMP/c592cd3b6e711d56ddd4ca7832b9b251 to your computer and use it in GitHub Desktop.
tiny babashka script that returns a random clojure doc
#!/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)
@CarnunMP
Copy link
Author

@CarnunMP
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment