Go to the first, previous, next, last section, table of contents.


The mapcar Function

mapcar is a function that calls its first argument with each element of its second argument, in turn. The second argument must be a sequence.

For example,

(mapcar '1+ '(2 4 6))
     => (3 5 7)

The function 1+ which adds one to its argument, is executed on each element of the list, and a new list is returned.

Contrast this with apply, which applies its first argument to all the remaining. (See section Readying a Graph, for a explanation of apply.)

In the definition of one-fiftieth, the first argument is the anonymous function:

(lambda (arg) (/ arg 50))

and the second argument is full-range, which will be bound to list-for-graph.

The whole expression looks like this:

(mapcar '(lambda (arg) (/ arg 50)) full-range))

See section `Mapping Functions' in The GNU Emacs Lisp Reference Manual, for more about mapcar.

Using the one-fiftieth function, we can generate a list in which each element is one-fiftieth the size of the corresponding element in list-for-graph.

(setq fiftieth-list-for-graph
      (one-fiftieth list-for-graph))

The resulting list looks like this:

(10 20 19 15 11 9 6 5 4 3 3 2 2 
1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 4)

This we are almost ready to print! (We also notice the loss of information: many of the higher ranges are 0, meaning that fewer than 50 defuns had that many words or symbols--but not necessarily meaning that none had that many words or symbols.)


Go to the first, previous, next, last section, table of contents.