I learnt about a function that I had forgotten today. The cond->
. Anyway, this inspired me to do a query
on the frequency of usage of the different functions of clojure. So I used the github api to get some repos, cloned and just ran a frequency analysis on each of the repos.
The regex was first a too simple thing, now updated with feedback from @seancorfield
(re-pattern
(->>
(map str (keys (ns-publics 'clojure.core)))
(map #(str "\\(" % "\\s"))
(map #(string/replace % "+" "\\+"))
(map #(string/replace % "*" "\\*"))
(map #(string/replace % "?" "\\?"))
(map #(string/replace % "." "\\."))
(interpose "|")
(apply str)))
now. the results, updated:
This is the top 100 used names from clojure.core
, with approx 400 repos analyzed.
Anyway, this distribution looks like a power-law thing, i.e. it follows zipf’s law.
I think this shows one side of the developer experience for Clojure, where one get a lot of power with very few functions!
This was all done in a bit more than 100 lines of code. (excluding plotting)
thanks to @seancorfield for pointing out the previosly really bad regex!
Cheers.