Kevin Kostlan
Kevin Kostlan

Reputation: 3519

Clojure list leiningen namespaces

Incanter, a graphing/plotting tool, works fine:

[incanter "1.5.6"] ; in project.clj
; in repl:
(do (use '(incanter core stats charts)) (view (histogram (sample-normal 1000))))

But how can I programmatically list namespaces from leiningen-dependencies? all-ns does not work:

; comes up empty UNTILL you (use 'incanter.charts):
(filterv #(.contains % "charts") (mapv str (all-ns)))

Is there a way to do this?

Upvotes: 2

Views: 102

Answers (1)

Piotrek Bzdyl
Piotrek Bzdyl

Reputation: 13185

(all-ns) returns only namespaces that has been already loaded (directly or indirectly, e.g. by using require or use).

For searching not-yet-loaded namespaces you can use tools.namespace and functions from its clojure.tools.namespace.find namespace.

Upvotes: 2

Related Questions