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: [mg122264] Re: count the number of sub-list in a list
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Sat, 22 Oct 2011 06:10:20 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201110211128.HAA18658@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

expr = {{{{-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}}}};

Depending on the detailed structure and how clearly you know it, one of  
these could be best:

Count[expr, {{_, _, _}, {_, _, _}, {_, _, _}}, {2}]

16

or

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

16

or

Dimensions@expr
Times @@ %[[;; 2]]

{4, 4, 3, 3}

16

Bobby

On Fri, 21 Oct 2011 06:28:15 -0500, Gy Peng <hitphyopt at gmail.com> 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


-- 
DrMajorBob at yahoo.com



  • Prev by Date: a bug in Integrate
  • Next by Date: a bug in Integrate (2nd message)
  • 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