Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: count the number of sub-list in a list
Replies: 4   Last Post: Oct 22, 2011 5:28 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
dimmechan@yahoo.com

Posts: 1,810
Registered: 6/20/06
Re: count the number of sub-list in a list
Posted: Oct 22, 2011 5:28 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2013. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.