sequencetools.yield_all_combinations_of_sequence_elements

abjad.tools.sequencetools.yield_all_combinations_of_sequence_elements.yield_all_combinations_of_sequence_elements(sequence, min_length=None, max_length=None)[source]

New in version 2.0.

Yield all combinations of sequence in binary string order:

abjad> from abjad.tools import sequencetools
abjad> list(sequencetools.yield_all_combinations_of_sequence_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]]

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

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

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

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

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

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

Return generator of newly created sequence objects.

Changed in version 2.0: renamed sequencetools.sublists() to sequencetools.yield_all_combinations_of_sequence_elements().

This Page