Skip to main content
added 195 characters in body
Source Link
E. Chan-López
  • 31.3k
  • 3
  • 29
  • 50
mx = {{a, b, c, d}, {e, f, g, h}, {i, j, k, l}, {m, n, o, p}};

mx2 = {{a, a + b, a + b + c, a + b + c + d}, {e, e + f, e + f + g, e + f + g + h}, 
      {i, i + j, i + j + k, i + j + k + l}, {m, m + n, m + n + o, m + n + o + p}};

A variation using FoldList:

FoldList[Apply[Plus]@*Flatten@*List, Nothing, #] & /@ mx === mx2

(*True*)
mx = {{a, b, c, d}, {e, f, g, h}, {i, j, k, l}, {m, n, o, p}};

mx2 = {{a, a + b, a + b + c, a + b + c + d}, {e, e + f, e + f + g, e + f + g + h}, 
      {i, i + j, i + j + k, i + j + k + l}, {m, m + n, m + n + o, m + n + o + p}};

A variation using FoldList:

FoldList[Apply[Plus]@*Flatten@*List, Nothing, #] & /@ mx === mx2

(*True*)
mx = {{a, b, c, d}, {e, f, g, h}, {i, j, k, l}, {m, n, o, p}};

mx2 = {{a, a + b, a + b + c, a + b + c + d}, {e, e + f, e + f + g, e + f + g + h}, 
      {i, i + j, i + j + k, i + j + k + l}, {m, m + n, m + n + o, m + n + o + p}};

A variation using FoldList:

FoldList[Apply[Plus]@*Flatten@*List, Nothing, #] & /@ mx === mx2

(*True*)
Source Link
E. Chan-López
  • 31.3k
  • 3
  • 29
  • 50

mx = {{a, b, c, d}, {e, f, g, h}, {i, j, k, l}, {m, n, o, p}};

mx2 = {{a, a + b, a + b + c, a + b + c + d}, {e, e + f, e + f + g, e + f + g + h}, 
      {i, i + j, i + j + k, i + j + k + l}, {m, m + n, m + n + o, m + n + o + p}};

A variation using FoldList:

FoldList[Apply[Plus]@*Flatten@*List, Nothing, #] & /@ mx === mx2

(*True*)