Skip to main content
added 125 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
ClearAll[foo];
foo[x : {___List?(VectorQ[#, NumberQ] &)}] := Plus @@@ x

foo[{{1, 2}, {2, 3, 4}}]

{3, 9}

foo[{{1, 2}, {{3}}}]

foo[{{1, 2}, {{3}}}]

Note: You need to use NumericQ in place of NumberQ if you want foo[{{1, 2}, {2, 3, π}}] to return {3, 2 + 3 π}.

ClearAll[foo];
foo[x : {___List?(VectorQ[#, NumberQ] &)}] := Plus @@@ x

foo[{{1, 2}, {2, 3, 4}}]

{3, 9}

foo[{{1, 2}, {{3}}}]

foo[{{1, 2}, {{3}}}]

ClearAll[foo];
foo[x : {___List?(VectorQ[#, NumberQ] &)}] := Plus @@@ x

foo[{{1, 2}, {2, 3, 4}}]

{3, 9}

foo[{{1, 2}, {{3}}}]

foo[{{1, 2}, {{3}}}]

Note: You need to use NumericQ in place of NumberQ if you want foo[{{1, 2}, {2, 3, π}}] to return {3, 2 + 3 π}.

Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

ClearAll[foo];
foo[x : {___List?(VectorQ[#, NumberQ] &)}] := Plus @@@ x

foo[{{1, 2}, {2, 3, 4}}]

{3, 9}

foo[{{1, 2}, {{3}}}]

foo[{{1, 2}, {{3}}}]