Is there a function/macro in Clojure to check what namespaces are currently ‘used’? Which one? So I don’t mean ‘what namespace are we currently in’ but for example, I want to find out if ‘clojure.contrib.string’ is currently ‘used’ as in (use 'clojure.contrib.string). I don’t mean ‘required’.
How does one write a function that give true when for example ‘clojure.contrib.string (the name of the namespace provided via a symbol) is used and false otherwise?
(defn ns-used? [name] (…)
all-ns as suggested by kotarak, is close to what you are looking for, but it also gives you all the namespaces that have been
requiredwithout having been referred.Otherwise ns-refers gives you a map of all the functions that are referred in the namespace. Similar and possibly also of interest are ns-map and ns-imports which gives you a mapping of all the imported classes or records.
If you want to strictly find all the namespaces from which functions have been referred, you could do something like this:
If you are happy to check if the namespace has been
requiredorusedyou could doYou will have to pass the symbol in quoted: