listtools.cumulative_sums

abjad.tools.listtools.cumulative_sums(l)

Return a list of the cumulative sums of the elements in l.

Note

len(listtools.cumulative_sums(l)) == len(l).

abjad> listtools.cumulative_sums([1, 2, 3, 4, 5, 6, 7, 8])
[1, 3, 6, 10, 15, 21, 28, 36]
abjad> listtools.cumulative_sums([1, -2, 3, -4, 5, -6, 7, -8])
[1, -1, 2, -2, 3, -3, 4, -4]

Raise TypeError when l is neither list nor tuple:

abjad> listtools.cumulative_sums('foo')
TypeError

Raise ValueError when l is empty:

abjad> listtools.cumulative_sums([ ])
ValueError

Previous topic

listtools.cumulative_products

Next topic

listtools.cumulative_sums_zero

This Page