Using SubsetMap
:
amat = {{1, a}, {2, b}, {3, c}, {4, d}}
SubsetMap[Accumulate, amat, {All, 2}]
Using FoldList
:
FoldList[{First@#2, Last@#1 + Last@#2} &, amat]
Result:
{{1, a}, {2, a + b}, {3, a + b + c}, {4, a + b + c + d}}
Using Construct
and MapThread
:
To apply different functions to columns, let's start with with a 3-column example matrix called bmat
.
bmat = {{1, a, w}, {2, b, x}, {3, c, y}, {4, d, z}}
funcs = {Identity, Accumulate, #^2 &};
Transpose@MapThread[Construct, {funcs, Transpose@bmat}] // TableForm
{{1, a, w^2}, {2, a + b, x^2}, {3, a + b + c, y^2}, {4, a + b + c + d,
z^2}}
$$\left(
\begin{array}{ccc}
1 & a & w^2 \\
2 & a+b & x^2 \\
3 & a+b+c & y^2 \\
4 & a+b+c+d & z^2 \\
\end{array}
\right)$$
Transpose[{list[[All, 1]], Accumulate@list[[All, 2]]}]
. $\endgroup$