yield_all_combinations_of_elements

sequencetools.yield_all_combinations_of_elements(sequence, min_length=None, max_length=None)

Yields all combinations of sequence in binary string order.

>>> list(sequencetools.yield_all_combinations_of_elements(
...     [1, 2, 3, 4]))
[[], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3], [4], [1, 4],
[2, 4], [1, 2, 4], [3, 4], [1, 3, 4], [2, 3, 4], [1, 2, 3, 4]]

Yields all combinations of sequence greater than or equal to min_length in binary string order:

>>> list(sequencetools.yield_all_combinations_of_elements(
...     [1, 2, 3, 4], min_length=3))
[[1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4], [1, 2, 3, 4]]

Yields all combinations of sequence less than or equal to max_length in binary string order:

>>> list(sequencetools.yield_all_combinations_of_elements(
...     [1, 2, 3, 4], max_length=2))
[[], [1], [2], [1, 2], [3], [1, 3], [2, 3], [4], [1, 4], [2, 4], [3, 4]]

Yields all combiantions of sequence greater than or equal to min_length and less than or equal to max_length in lex order:

>>> list(sequencetools.yield_all_combinations_of_elements(
...     [1, 2, 3, 4], min_length=2, max_length=2))
[[1, 2], [1, 3], [2, 3], [1, 4], [2, 4], [3, 4]]

Yields references to sequence elements; does not copy sequence elements.

Returns generator.