I have a list

l={{0, 0, 0, 3}, {0, 0, 0, 3}, {0, 0, 1, 2}}

And I would like to obtain the number of zeros in each sublist:

NZ=Table[Count[l[[i]], 0], {i, Length[l]}]

which will return the list: {3,3,2} .

Is there a way to use Map to accomplish this more cleanly?

What I would like to do is write something like: Map[Count, l] which will of course fail because Count needs a pattern to count.

  • 1
    $\begingroup$ Also have a look here and here (I am sure there were still more). $\endgroup$ – Leonid Shifrin Mar 19 '14 at 14:58
  • $\begingroup$ Thanks. Sorry I duplicated previous posts. I searched but it often isn't obvious what to search for. $\endgroup$ – JEP Mar 20 '14 at 15:07

Browse other questions tagged or ask your own question.