Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: count the number of sub-list in a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg122243] Re: count the number of sub-list in a list
  • From: Shizu <slivo.vitz at msa.hinet.net>
  • Date: Sat, 22 Oct 2011 06:06:32 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

To find all the elements you need, use

Position[list, {{_, _, _}, {_, _, _}, {_, _, _}}]

So, you see the elements are all at level 2, since each element has 2 indices.

Count[list, _List, {2}]  will give you the number of elements.

Or else, you would say,

Count[list, {{_, _, _}, {_, _, _}, {_, _, _}}, Infinity]

This also gives the result, but you don't need to know the position/level of your elements.

If you type TreeForm[list], you'll see the "shape" of your list.  And figure out how to count them.



  • Prev by Date: strange error
  • Next by Date: Re: Problem with "Which"
  • Previous by thread: Re: count the number of sub-list in a list
  • Next by thread: Re: count the number of sub-list in a list