开发者

How do I count a List of Lists?

开发者 https://www.devze.com 2023-02-21 10:37 出处:网络
Thanks again everyone, I can\'t believe how far this has come. Almost there. How do I ex开发者_开发技巧tend the Length function.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消