Common Lisp has over 700 functions in its core libraries. Roughly how many does Clojure have in its libraries?
(Where 'core library' is defined as everything you get access to when you include [org.clojure/clojure "1.5.1"]
in your project.clj
)
(Update: Inspired by this question, I have released Varspotting, a Leiningen plugin and library for producing reports on data of this kind. The reports for Clojure 1.5.1 are displayed in the README; see also my comment below for the numbers. The minor differences between those counts and the ones in the answer below are a result of the REPL environment including certain bindings which Varspotting omits from its counts.)
Using Clojure 1.5.1.
The clojure.core
namespace:
Public Vars:
(count (ns-publics 'clojure.core))
;= 591
Public Vars which hold non-macro functions (the filter function is meant to exclude the 6 Vars which hold maps, see below for how to find them; there are not sets or vectors to exclude at this time):
(->> (ns-publics 'clojure.core)
vals
(filter #(not (.isMacro %)))
(map deref)
(filter (every-pred ifn? (comp not map?)))
count)
;= 477
With #(.isMacro %)
in the filter
above, we find there are 76 public macros.
The 32 public Vars which do not hold function-like values can be discovered with this snippet:
(->> (ns-publics 'clojure.core)
vals
(remove (comp ifn? deref)))
Use (filter (comp map? deref))
instead of the (remove ...)
in the above to find the 6 Vars holding map values.
Same as 2. for all namespaces in the Clojure jar (skipping the deprecated clojure.parallel
and additionally excluding the two Vars holding vectors; there are no sets to exclude at this time; hopefully haven't missed anything else):
(dorun (map require '[clojure.core clojure.data clojure.edn clojure.inspector
clojure.instant clojure.java.browse clojure.java.javadoc
clojure.java.io clojure.java.shell
clojure.main clojure.pprint clojure.reflect clojure.repl
clojure.set clojure.stacktrace clojure.string
clojure.template clojure.test clojure.walk clojure.xml
clojure.zip]))
(->> (mapcat ns-publics
'[clojure.core
clojure.data
clojure.edn
clojure.inspector
clojure.instant
clojure.java.browse
clojure.java.javadoc
clojure.java.io
clojure.java.shell
clojure.main
clojure.pprint
clojure.reflect
clojure.repl
clojure.set
clojure.stacktrace
clojure.string
clojure.template
clojure.test
clojure.walk
clojure.xml
clojure.zip])
vals
(filter #(not (.isMacro %)))
(map deref)
(filter (every-pred ifn? (comp not map?) (comp not vector?)))
count)
;= 676
For macros, the total count is 99.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With