Skip to content

Instantly share code, notes, and snippets.

@CarnunMP
Last active November 23, 2022 15:15
Embed
What would you like to do?
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