yield_all_compositions_of_integer

mathtools.yield_all_compositions_of_integer(n)

Yields all compositions of positive integer n.

>>> import abjad
>>> for tuple_ in abjad.mathtools.yield_all_compositions_of_integer(5):
...     tuple_
...
(5,)
(4, 1)
(3, 2)
(3, 1, 1)
(2, 3)
(2, 2, 1)
(2, 1, 2)
(2, 1, 1, 1)
(1, 4)
(1, 3, 1)
(1, 2, 2)
(1, 2, 1, 1)
(1, 1, 3)
(1, 1, 2, 1)
(1, 1, 1, 2)
(1, 1, 1, 1, 1)

Lists parts in descending lex order.

Parts sum to n.

Finds small values of n easily.

Takes around 4 seconds for n equal to 17.

Returns integer tuple generator.