I want to take a nested list and replace each sub-list with an arithmetic operation on its elements. For example: a={{1,3},{2,2},{2,3}}. I want to get {4,4,5}. I can do it by: f{x_,y_}=x+y and then Map[f,a] but I suspect that there has to be an easier way by applying rules or similar.
Map
is the straightforward way to go. You can use pure functions instead of definingf[x, y]
. In this particular case,Plus @@@ a
works. In pure functions:(#1 + #2) & @@@ a
. $\endgroup$Total
with a level spec is designed for this purpose ..as per Carls answer $\endgroup$