yield_all_subsequences_of_sequence

sequencetools.yield_all_subsequences_of_sequence(sequence, min_length=0, max_length=None)

Yields all subsequences of sequence.

Yields subsequences in lex order.

>>> list(sequencetools.yield_all_subsequences_of_sequence([0, 1, 2]))
[[], [0], [0, 1], [0, 1, 2], [1], [1, 2], [2]]

Yields all subsequences of sequence greater than or equal to min_length in lex order:

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

Yields all subsequences of sequence less than or equal to max_length in lex order:

>>> for subsequence in sequencetools.yield_all_subsequences_of_sequence(
...     [0, 1, 2, 3, 4], max_length=3):
...     subsequence
[]
[0]
[0, 1]
[0, 1, 2]
[1]
[1, 2]
[1, 2, 3]
[2]
[2, 3]
[2, 3, 4]
[3]
[3, 4]
[4]

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

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

Returns generator.