Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5768 > unrolled thread

count the number of sub-list in a list

Started byGy Peng <hitphyopt@gmail.com>
First post2011-10-21 11:29 +0000
Last post2011-10-22 10:16 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  count the number of sub-list in a list Gy Peng <hitphyopt@gmail.com> - 2011-10-21 11:29 +0000
    Re: count the number of sub-list in a list dimitris <dimmechan@yahoo.com> - 2011-10-22 10:13 +0000
    Re: count the number of sub-list in a list Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-10-22 10:16 +0000

#5768 — count the number of sub-list in a list

FromGy Peng <hitphyopt@gmail.com>
Date2011-10-21 11:29 +0000
Subjectcount the number of sub-list in a list
Message-ID<j7rl28$i7v$1@smc.vnet.net>
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

[toc] | [next] | [standalone]


#5785

Fromdimitris <dimmechan@yahoo.com>
Date2011-10-22 10:13 +0000
Message-ID<j7u515$t7n$1@smc.vnet.net>
In reply to#5768
On Oct 21, 2:29 pm, Gy Peng <hitphy...@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

I must admit that I am not exactly sure what you want.
I guess something from the following will be helpful.

In[137]:=
lst = {{{{-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}}}};

In[152]:= Length[lst]
Length /@ lst
Map[Length, lst, {2}]

Out[152]= 4

Out[153]= {4, 4, 4, 4}

Out[154]= {{3, 3, 3, 3}, {3, 3, 3, 3}, {3, 3, 3, 3}, {3, 3, 3, 3}}

Dimitris

[toc] | [prev] | [next] | [standalone]


#5789

FromArmand Tamzarian <mike.honeychurch@gmail.com>
Date2011-10-22 10:16 +0000
Message-ID<j7u553$t8g$1@smc.vnet.net>
In reply to#5768
On Oct 21, 10:29 pm, Gy Peng <hitphy...@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

In= Dimensions[yourList]

Out= {4, 4, 3, 3}

your defined single elements are 3 x 3 and you have 4 x 4 of these.

Mike

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web