listtools.sum_slices_at — Abjad v1.1.1 documentation

### Navigation

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

# listtools.sum_slices_at

`abjad.tools.listtools.` `sum_slices_at`(l, pairs, period=None, rump=True)

  Sum elements in `l` according to `pairs`. For each `(i, count)` in `pairs`, replace `l[i:i+count]` with `sum(l[i:i+count])`.

  > - When `period` is a positive integer, read `pairs` cyclically.
  > - When `rump = False` do not append incomplete final sum.

  Examples:

      abjad> l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
      abjad> listtools.sum_slices_at(l, [(0, 2)], period = 4)
      [1, 2, 3, 9, 6, 7, 17, 10]

      abjad> l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
      abjad> listtools.sum_slices_at(l, [(0, 3)], period = 4)
      [6, 3, 15, 7, 27]

      abjad> l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
      abjad> listtools.sum_slices_at(l, [(0, 4)], period = 4)
      [6, 22, 27]

  When `period` is not `None`, indices in `pairs` must be less than `period`.

### Navigation

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