Question

How to list the functions of a namespace?

#clojure

Answer

clojure.repl/dir prints a sorted directory of public vars in a namespace

(clojure.repl/dir clojure.string)

Notice that dir is a macro and so it doesn't evaluate its arguments. This is why (dir *ns*) doesn't work. In this case dir-fn can be used instead.

[^1]: http://stackoverflow.com/questions/2747294/how-to-list-the-functions-of-a-namespace
[^2]: https://clojure.github.io/clojure/clojure.repl-api.html#clojure.repl/dir
[^3]: (dir *ns*) doesn't work??
[^4]: https://clojuredocs.org/clojure.repl/dir-fn

Learn

Author

xavi

Reviews
Last
next

Students 1