Skip to content

Instantly share code, notes, and snippets.

@athos
Created December 6, 2012 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save athos/4224221 to your computer and use it in GitHub Desktop.
Save athos/4224221 to your computer and use it in GitHub Desktop.
clojure.coreで定義されている変数・関数名の長さのリスト。名前の平均の長さは約8.3文字。
user=> (def freq (frequencies (map #(count (str %)) (keys (ns-publics 'clojure.core)))))
#'user/freq
user=> (doseq [[l n] freq] (printf "%2d %s\n" l (apply str (repeat n \*))))
1 *******
2 ****************
3 ****************************
4 **********************************************************************
5 *******************************************************
6 ********************************************************
7 ****************************************************************
8 ***************************************
9 *********************************************
10 **********************************************
11 **********************************
12 **********************
13 ************************
14 ****************
15 ****************
16 *******
17 ******
18 **********
19 ***
20 ********
21 ***
22 **
23 **
25 *
nil
user=> (double (/ (apply + (for [[l n] freq] (* l n))) (apply + (vals freq))))
8.348275862068967
user=>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment