listtools.cumulative_weights_signed — Abjad v1.1.1 documentation

### Navigation

- index
- modules |
- next |
- previous |
- Project Abjad »
- Abjad v1.1.1 documentation »
- Abjad API »

# 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

### Navigation

- index
- modules |
- next |
- previous |
- Project Abjad »
- Abjad v1.1.1 documentation »
- Abjad API »