Count
Usage
• Count[list, pattern]给出了list中匹配pattern的元素个数。
• Count[expr, pattern, levelspec] 给出了匹配pattern的子表达式的总个数,这些子表达式出现在expr中由levelspec指定的级别上。
Notes
Further Examples
(See the Further Examples for FullSimplify for a demonstration of how Count can be used to affect the outcome of a simplification.) This counts the number of occurrences of Real numbers in the list. (An Integer is not considered to be Real, any more than a Real is considered to be Complex.)
In[1]:=
|
Out[1]=
|
This command returns the number of summands that are powers. (Note that the first argument to Count need not be a list.)
In[2]:=
|
Out[2]=
|
This returns the number of expressions that occur in the sum at any level and are powers. This count is higher; the actual matches can be seen by replacing Count with Cases.
In[3]:=
|
Out[3]=
|
|