Re: HELP: How to do count to the SUB-LIST

• To: mathgroup at smc.vnet.net
• Subject: [mg82166] Re: HELP: How to do count to the SUB-LIST
• From: Bill Rowe <readnewsciv at sbcglobal.net>
• Date: Sat, 13 Oct 2007 04:02:43 -0400 (EDT)

```On 10/12/07 at 2:51 AM, wangzhen0829 at gmail.com (zhen) wrote:

>I am new to Mathematica, and I get one problem now, hope to get some
>help here

>I got a list like this:

>{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 1, 0, 0, 0, 1, 0, 0, 0}, {0,
>0, 0, 0, 1, 1, 0, 0, 2, 0}, {1, 0, 1, 0, 0, 1, 0, 1, 0, 0}, {1, 3,
>3, 4, 2, 2, 5, 3, 2, 1}, {7, 2, 2, 3, 4, 4, 0, 3, 1, 3}}

>I need to get a list to show the number of non zero number in each
>sub list, as to say, I need to get a list like this:

>{0,3,3,4,10,9}

Here are a few different ways:

=46irst, noting all of the non-zero values are positive

In[10]:= Plus @@@ Sign[data]

Out[10]= {0,3,3,4,10,9}

or

In[11]:= Total[Transpose@Sign@data]

Out[11]= {0,3,3,4,10,9}

or if there were arbitrary items other than 0

In[12]:= Length[DeleteCases[#, 0]] & /@ data

Out[12]= {0,3,3,4,10,9}
--
To reply via email subtract one hundred and four

```

• Prev by Date: Re: HELP: How to do count to the SUB-LIST
• Next by Date: Re: HELP: How to do count to the SUB-LIST
• Previous by thread: Re: HELP: How to do count to the SUB-LIST
• Next by thread: Re: HELP: How to do count to the SUB-LIST