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: [mg122262] Re: count the number of sub-list in a list
  • From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
  • Date: Sat, 22 Oct 2011 06:09:59 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201110211128.HAA18658@smc.vnet.net> <524BB95F-6A5A-4EFE-AFFD-CCEFCB07FDDE@trm.uni-leipzig.de> <CAF+B5XZRVLeHB1SKsBW0=aohepPu5_CeH3Gs_bA+C3TRR39Sqg@mail.gmail.com>

Sorry,

as always I read too sloppy, but you can just adopt my example:

Count[m, {
	{_Real, _Real, _Real},
	{_Real, _Real, _Real},
	{_Real,_Real, _Real} }, Infinity]

but you can shorten this to

Count[m, {{_Real ..} ..}, Infinity]

Cheers
Patrick


On Oct 21, 2011, at 1:51 PM, Gy Peng wrote:

> Dear Patrick,
>
> Thanks a lot for your kind reply.
>
> Sorry, what I want to count is not {_Real, _Real, _Real} but {{_Real, _Real, _Real},{_Real, _Real, _Real},{_Real, _Real, _Real}}, which is a matrix.
>
> "Count[m, {_Real, _Real, _Real}, -1]" only gave me the number of {_Real, _Real, _Real}, in my list.
>
> I tired Count[m, {_Real, _Real, _Real}, -2] or Count[m, {_Real, _Real, _Real}, 1] or Count[m, {_Real, _Real, _Real}, 2], they all gave me output=0
> I do not know what is the problem.
>
> I would appreciate if you could give some further help. Thanks for your time!
>
> Best regards,
> Gy Peng
>
>
> 2011/10/21 Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
> Hi,
>
> in your tensor m the elements you want to count have the Form {_Real, _Real, _Real}
> and they are in the last level (-1) of your structure:
>
> Count[m, {_Real, _Real, _Real}, -1]
>
> or you just use the Dimension of m with the last level droped and multiply them
>
> Times @@ Most@Dimensions[m]
>
> both should give the same result.
>
> Cheers
> Patrick
>
>
> On Oct 21, 2011, at 1:28 PM, Gy Peng wrote:
>
> > Dear All,
> >
> > I have a list like:
> >
> > {{{{-0.00201671, 0.87571, 0.482832}, {-0.839678,
> >    0.260735, -0.476401}, {-0.543081, -0.406384,
> >    0.734789}}, {{-0.87571, -0.00201671,
> >    0.482832}, {-0.260735, -0.839678, -0.476401}, {0.406384, -0.543081,
> > 0.734789}}, {{0.00201671, -0.87571,
> >    0.482832}, {0.839678, -0.260735, -0.476401}, {0.543081, 0.406384,
> >    0.734789}}, {{0.87571, 0.00201671, 0.482832}, {0.260735,
> >    0.839678, -0.476401}, {-0.406384, 0.543081,
> >    0.734789}}}, {{{0.839678, -0.260735, 0.476401}, {-0.00201671,
> >    0.87571, 0.482832}, {-0.543081, -0.406384, 0.734789}}, {{0.260735,
> >     0.839678, 0.476401}, {-0.87571, -0.00201671,
> >    0.482832}, {0.406384, -0.543081, 0.734789}}, {{-0.839678,
> >    0.260735, 0.476401}, {0.00201671, -0.87571, 0.482832}, {0.543081,
> >    0.406384, 0.734789}}, {{-0.260735, -0.839678, 0.476401}, {0.87571,
> >     0.00201671, 0.482832}, {-0.406384, 0.543081,
> >    0.734789}}}, {{{0.00201671, -0.87571, -0.482832}, {0.839678, -0.260735,
> > 0.476401}, {-0.543081, -0.406384, 0.734789}}, {{0.87571,
> >    0.00201671, -0.482832}, {0.260735, 0.839678,
> >    0.476401}, {0.406384, -0.543081, 0.734789}}, {{-0.00201671,
> >    0.87571, -0.482832}, {-0.839678, 0.260735, 0.476401}, {0.543081,
> >    0.406384,
> >    0.734789}}, {{-0.87571, -0.00201671, -0.482832}, {-0.260735, -0.839678,
> > 0.476401}, {-0.406384, 0.543081, 0.734789}}}, {{{-0.839678,
> >     0.260735, -0.476401}, {0.00201671, -0.87571, -0.482832}, {-0.543081,
> > -0.406384,
> >    0.734789}}, {{-0.260735, -0.839678, -0.476401}, {0.87571,
> >    0.00201671, -0.482832}, {0.406384, -0.543081,
> >    0.734789}}, {{0.839678, -0.260735, -0.476401}, {-0.00201671,
> >    0.87571, -0.482832}, {0.543081, 0.406384, 0.734789}}, {{0.260735,
> >    0.839678, -0.476401}, {-0.87571, -0.00201671, -0.482832}, {-0.406384,
> > 0.543081, 0.734789}}}}
> >
> > I consider each of {{*, *, *}, {*, *, *}, {*,*,*}} is one single element, so
> > how could I count how many element in the whole list? Thank you very much!
> >
> > G
> >
>
>




  • Prev by Date: Re: count the number of sub-list in a list
  • Next by Date: Re: count the number of sub-list in a list
  • 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