Next: lambda, Previous: Test print-graph, Up: Print Whole Graph [Contents][Index]
Now for the graph for which all this code was written: a graph that shows how many function definitions contain fewer than 10 words and symbols, how many contain between 10 and 19 words and symbols, how many contain between 20 and 29 words and symbols, and so on.
This is a multi-step process. First make sure you have loaded all the requisite code.
It is a good idea to reset the value of top-of-ranges
in case you
have set it to some different value. You can evaluate the following:
(setq top-of-ranges '(10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300)
Next create a list of the number of words and symbols in each range.
Evaluate the following:
(setq list-for-graph (defuns-per-range (sort (recursive-lengths-list-many-files (directory-files "/usr/local/emacs/lisp" t ".+el$")) '<) top-of-ranges))
On my old machine, this took about an hour. It looked though 303 Lisp files
in my copy of Emacs version 19.23. After all that computing, the
list-for-graph
had this value:
(537 1027 955 785 594 483 349 292 224 199 166 120 116 99 90 80 67 48 52 45 41 33 28 26 25 20 12 28 11 13 220)
This means that my copy of Emacs had 537 function definitions with fewer than 10 words or symbols in them, 1,027 function definitions with 10 to 19 words or symbols in them, 955 function definitions with 20 to 29 words or symbols in them, and so on.
Clearly, just by looking at this list we can see that most function definitions contain ten to thirty words and symbols.
Now for printing. We do not want to print a graph that is 1,030 lines high … Instead, we should print a graph that is fewer than twenty-five lines high. A graph that height can be displayed on almost any monitor, and easily printed on a sheet of paper.
This means that each value in list-for-graph
must be reduced to
one-fiftieth its present value.
Here is a short function to do just that, using two functions we have not
yet seen, mapcar
and lambda
.
(defun one-fiftieth (full-range) "Return list, each number one-fiftieth of previous." (mapcar (lambda (arg) (/ arg 50)) full-range))
Next: lambda, Previous: Test print-graph, Up: Print Whole Graph [Contents][Index]