How do I count a List of Lists?
Thanks again everyone, I can't believe how far this has come. Almost there.
How do I ex开发者_开发技巧tend the Length function.
i.e.
I can count {1,3}
by Length[{1,3}]
2
But how do I count the length of each set in the list {{1,3}, {1,1,3}, ...}
?
Just try
Length /@ {{1},{1,2,3}}
Which is an abbreviation of:
Map[Length, {{1},{1,2,3}}]
Map
applies a function (in this case Length[]
)element-wise over lists.
精彩评论