listtools.cumulative_weights_signed

abjad.tools.listtools.cumulative_weights_signed(l)

Yield signed weights of the cumulative elements in l

Note

This function returns a generator.

abjad> l = [1, -2, -3, 4, -5, -6, 7, -8, -9, 10]
abjad> list(listtools.cumulative_weights_signed(l))
[1, -3, -6, 10, -15, -21, 28, -36, -45, 55]
abjad> l = [-1, -2, -3, -4, -5, 6, 7, 8, 9, 10]
abjad> list(listtools.cumulative_weights_signed(l))
[-1, -3, -6, -10, -15, 21, 28, 36, 45, 55]
abjad> l = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
abjad> list(listtools.cumulative_weights_signed(l))
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
abjad> l = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0]
abjad> list(listtools.cumulative_weights_signed(l))
[1, 3, 6, 10, 15, 15, 15, 15, 15, 15]
abjad> l = [-1, -2, -3, -4, -5, 0, 0, 0, 0, 0]
abjad> list(listtools.cumulative_weights_signed(l))
[-1, -3, -6, -10, -15, -15, -15, -15, -15, -15]

Note

For cumulative (unsigned) weights use listtools.cumulative_sums([abs(x) for x in l]).

Raise TypeError when l is not a list:

abjad> list(listtools.cumulative_weights_signed('foo'))
TypeError

Previous topic

listtools.cumulative_sums_zero

Next topic

listtools.difference_series

This Page