listtools.flatten — Abjad v1.1.1 documentation

### Navigation

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

# listtools.flatten

`abjad.tools.listtools.` `flatten`(l, ltypes=(<type 'list'>, <type 'tuple'>), depth=2147483647)

  Flatten nested lists l. Return a 0-depth list or tuple. Set optional depth keyword set to positive integer. Keyword controls depth to which the function operates. Based on Mike C. Fletcher’s flatten.

      abjad> t = [1, [2, 3, [4]], 5, [6, 7, [8]]]
      abjad> listtools.flatten(t)
      [1, 2, 3, 4, 5, 6, 7, 8]

      abjad> listtools.flatten(t, depth = 0)
      [1, [2, 3, [4]], 5, [6, 7, [8]]]

      abjad> listtools.flatten(t, depth = 1)
      [1, 2, 3, [4], 5, 6, 7, [8]]

      abjad> listtools.flatten(t, depth = 2)
      [1, 2, 3, 4, 5, 6, 7, 8]

### Navigation

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