How do I get the row sum of a table?

   ]t=:?.4 5$10
6 5 9 2 4
9 0 7 0 4
6 8 3 8 1
2 8 0 0 2
   +/t    NB. this is column sum
23 21 19 10 11

How do I get the row sum of a table?

Use Rank adverb

   +/"1 t
26 20 26 12

   +/ rows t
26 20 26 12

   +/ items t
26 20 26 12

Explanation

+/'s verb rank is _, which means + is inserted in between items (the highest rank cells). You need a verb with rank 1, which means + is inserted between atoms for each line.


Contributed by Your Name

Guides/Language FAQ/Row Sum (last edited 2008-12-08 10:45:48 by )