MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Count inside a matrix?


Use the 3rd argument of Count to specify the level down which to go in
the pattern matching.  E.g.:

In[1]:= mat = {
  {1, a, b, \[Pi]},
  {E, 2, 3, 1/3}
  }

Out[1]= {{1, a, b, \[Pi]}, {E, 2, 3, 1/3}}

In[2]:= Count[mat, _Integer, 2]

Out[2]= 3



On Sep 8, 3:11 am, Sergio Sergio <zerg... at gmail.com> wrote:
> Hi, does anybody know how to count elements within a matrix?
> I know how that Count works for lists, but it does not seem to work for a matrix.
> Any tips?
>
> Thanks




  • Prev by Date: Re: FrontEnd: Rotation of "heavy" graphics objects
  • Next by Date: Re: A new FrontEnd
  • Previous by thread: Re:Count inside a matrix?
  • Next by thread: How on Earth?