DeleteCases
First I define (lst) which will be used to demonstrate DeleteCases.
The first example deletes all real numbers at level 1 and the only one at that level was 1.2. Recall 1, 2, 3, ... have the head Integer not Real.
The next example deletes all Real numbers at levels 1 through 3. The integers deleted were 1.2, 1.3, 1.4. More discussion on level specification is given in another section.
The next example deletes Real numbers at level 3. The only Real number at level 3 was 1.4.
The next example deletes all Real numbers at any level.
In the next example I give an alternate way to delete Real numbers at any level.
In the next example I give an alternate way to delete Real numbers at levels 1 through 3.
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
DeleteCases has a Heads option with the default setting (Heads→False). First I define (expr) which will be used to demonstrate this option.
In the next cell DeleteCases ignores the (h) in h[x,y] because of the default setting for Heads.
When the previous example is repeated with the option (Heads→True) the (h) in h[x,y] is deleted.
Below I give alternate methods of getting the same results as the last two examples.
Created by Mathematica (May 16, 2004)