One useful operation which appears all the time in laying out documents & UIs ar...

@alcinnz@floss.social

One useful operation which appears all the time in laying out documents & UIs are running-sums!

For instance the running sum of: 5, 2, 1, 2, 2, 6, 5, 1
is: 5, 7, 8, 10, 12, 18, 23, 24

The sequential algorithm is obvious but another way to compute this which maximizes concurrency is to repeatedly sum pairs together:

5, 2, 1, 2, 2, 6, 5, 1
_, 7, _, 3, _, 8, _, 6
_, _, _,10,_, _, _, 14
_, _, _, _, _, _, _, 24

To give us: 5, 7, 7 + 1, 10, 10+2, 10+8, 10+8+5, 24

1/2!