2
$\begingroup$

I have the following output:

{{{0, 1}}, {{1, 1}, {1, 2}}, {{2, 1}, {2, 3}}, {{3, 1}, {3, 2}, {3, 3}, {3, 4}}}

Using Length[] on this, gives 5. But I want to get the number of all possibilities so I want the number 9. How do I manipulate a code using Length[]?

$\endgroup$
2
  • 1
    $\begingroup$ {{{0, 1}}, {{1, 1}, {1, 2}}, {{2, 1}, {2, 3}}, {{3, 1}, {3, 2}, {3, 3}, {3, 4}}}~Level~{-2} // Length $\endgroup$
    – cvgmt
    Commented Oct 17, 2020 at 14:45
  • $\begingroup$ also Count[#,{__Integer},2]@lists. $\endgroup$
    – kglr
    Commented Oct 17, 2020 at 22:18

1 Answer 1

2
$\begingroup$

You need to check each length and add them up. See the function f below:

f = Total@*Map[Length]
f[{{{0, 1}}, {{1, 1}, {1, 2}}, {{2, 1}, {2, 3}}, {{3, 1}, {3, 2}, {3, 3}, {3, 4}}}]

gives

9
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.