Partition list l into sublists r_i in result list such that len(r)_i == counts_i for all i < len(result).
Input:
Output: Python list of one or more sublists.
abjad> l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
abjad> listtools.partition_by_lengths(l, [3])
[[0, 1, 2]]
When cyclic = True repeat the elements in counts.
abjad> l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
abjad> listtools.partition_by_lengths(l, [3], cyclic = True)
[[0, 1, 2], [3, 4, 5], [6, 7, 8]]
When overhang = True return any remaining unicorporated elements of l as a final part in result.
abjad> l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
abjad> listtools.partition_by_lengths(l, [3], overhang = True)
[[0, 1, 2], [3, 4, 5, 6, 7, 8, 9]]
When both cyclic = True and overhang = True repeat the elements in counts and return any remaining unincorporated elements of l as a final part in result.
abjad> l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
abjad> listtools.partition_by_lengths(l, [3], cyclic = True, overhang = True)
[[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]
Examples with 1 < len(counts).
abjad> l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
abjad> listtools.partition_by_lengths(l, [4, 3])
[[0, 1, 2, 3], [4, 5, 6]]
abjad> l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
abjad> listtools.partition_by_lengths(l, [4, 3], cyclic = True)
[[0, 1, 2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13]]
abjad> l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
abjad> listtools.partition_by_lengths(l, [4, 3], overhang = True)
[[0, 1, 2, 3], [4, 5, 6], [7, 8, 9, 10, 11, 12, 13, 14, 15]]
abjad> l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
abjad> listtools.partition_by_lengths(
l, [4, 3], cyclic = True, overhang = True)
[[0, 1, 2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13], [14, 15]]