How can I add the elements in the sublists?
For example, if I have the list which is
m={{1,3},{2,3},{4,1}}
then, the output that I want is 3+3+1=10.
How can I do this?
|
How can I add the elements in the sublists?
then, the output that I want is |
||||
| show 3 more comments |
|
I thinks the cleanest way is:
using Esc[[Esc and Esc]]Esc. If you use it a lot (like me), you can create shortcuts as explained here. |
|||||
|
|
Following @b.gatessucks
If you want to sum all components (as @image_doctor pointed out too, sorry I missed that)
|
|||||
|
or
for both components |
|||
|
|
Partto get the elements from the list, thenTotalto sum them up. – b.gatessucks Oct 30 '12 at 9:44Plus @@@ (m\[Transpose])will give you a list of the sums of the various elements of your list. – image_doctor Oct 30 '12 at 10:00