Message Boards Message Boards

4 Replies
0 Total Likes
View groups...
Share this post:

how to collapse lists of vectors ?

Posted 10 years ago

this is most likely a total noob question, but i cannot find a solution :/

i have a list of vectors
{{a,b,c}, {d,e,f}, {g,h,i}}

and i want to add all of these vector so it yields
{a+d+g, b+e+h, c+f+i}

what would be the appropriate function to do so in mathematica ?

POSTED BY: xort dsc
4 Replies
Posted 10 years ago
ah cool, that's it. thank you very much. emoticon
POSTED BY: xort dsc
Oops, gave away the answer to the suggestion...  ;-)
POSTED BY: David Reiss
Apply[Plus, {{a, b, c}, {d, e, f}, {g, h, i}}]
 same as
Plus @@ {{a, b, c}, {d, e, f}, {g, h, i}}

There are always many ways to do things in Mathematica...
MapThread[Plus, {{a, b, c}, {d, e, f}, {g, h, i}}]

Plus @@@ Transpose[{{a, b, c}, {d, e, f}, {g, h, i}}]
POSTED BY: David Reiss
Posted 10 years ago
Hint: Look up the Apply function in the help system and experiment with that.
POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract