How to get the namespace of a var in Clojure?

Viewed 736

I am currently using the following which works - but it seems a bit of a cludge

(defn get-namespace
  [qualified-var]
  {:pre [(var? qualified-var)]}
  (the-ns
   (symbol
    (apply str (drop 2 (first (str/split (str qualified-var) #"/")))))))

ignoring the ugly string splitting (quick and dirty) is there a built in to do this?

1 Answers
Related