Count
First I define (lst) which will be used to demonstrate Count.
The following returns 3 because lst has three elements and each has the form (_List).
The three lists found with the example from the previous cell are returned by evaluating the next input.
The next input counts six lists at level 2.
The six lists found with the example from the previous cell are returned by evaluating the next input.
The next input counts ten lists at levels zero through 2.
The ten lists found with the example from the previous cell are returned by evaluating the next input.
I don't provide further examples, but any combination of pattern matching constructs can be used with Count. Nuances of pattern matching are discussed in another section.
Heads Option
Count has a Heads option with the default setting (Heads→False). First I define (expr) which will be used to demonstrate this option. In the first example Count ignores the (h) in h[x,y] because of the default setting for Heads.
When the last example is repeated using (Heads→True) the (h) in h[x,y] is accounted for.
Created by Mathematica (May 16, 2004)