Skip to main content
added 70 characters in body
Source Link
Mike Honeychurch
  • 37.8k
  • 3
  • 87
  • 161
Accumulate@Array[b, {3}]
(* {b[1], b[1] + b[2], b[1] + b[2] + b[3]} *)

therefore:

{a, b} = Transpose[list];
Transpose[{a, Accumulate[b]}]

Also this will do the job:

Rest@FoldList[{#2[[1]], #1[[2]] + #2[[2]]} &, {0, 0}, list]

or even easier

list[[All,2]]=Accumulate@list[[All,2]]; list
Accumulate@Array[b, {3}]
(* {b[1], b[1] + b[2], b[1] + b[2] + b[3]} *)

therefore:

{a, b} = Transpose[list];
Transpose[{a, Accumulate[b]}]

Also this will do the job:

Rest@FoldList[{#2[[1]], #1[[2]] + #2[[2]]} &, {0, 0}, list]
Accumulate@Array[b, {3}]
(* {b[1], b[1] + b[2], b[1] + b[2] + b[3]} *)

therefore:

{a, b} = Transpose[list];
Transpose[{a, Accumulate[b]}]

Also this will do the job:

Rest@FoldList[{#2[[1]], #1[[2]] + #2[[2]]} &, {0, 0}, list]

or even easier

list[[All,2]]=Accumulate@list[[All,2]]; list
added 95 characters in body
Source Link
Mike Honeychurch
  • 37.8k
  • 3
  • 87
  • 161
Accumulate@Array[b, {3}]
(* {b[1], b[1] + b[2], b[1] + b[2] + b[3]} *)

therefore:

{a, b} = Transpose[list];
Transpose[{a, Accumulate[b]}]

Also this will do the job:

Rest@FoldList[{#2[[1]], #1[[2]] + #2[[2]]} &, {0, 0}, list]
Accumulate@Array[b, {3}]
(* {b[1], b[1] + b[2], b[1] + b[2] + b[3]} *)

therefore:

{a, b} = Transpose[list];
Transpose[{a, Accumulate[b]}]
Accumulate@Array[b, {3}]
(* {b[1], b[1] + b[2], b[1] + b[2] + b[3]} *)

therefore:

{a, b} = Transpose[list];
Transpose[{a, Accumulate[b]}]

Also this will do the job:

Rest@FoldList[{#2[[1]], #1[[2]] + #2[[2]]} &, {0, 0}, list]
Source Link
Mike Honeychurch
  • 37.8k
  • 3
  • 87
  • 161

Accumulate@Array[b, {3}]
(* {b[1], b[1] + b[2], b[1] + b[2] + b[3]} *)

therefore:

{a, b} = Transpose[list];
Transpose[{a, Accumulate[b]}]