egttools.utils.combine

combine(values, length)[source]

Outputs a generator that will generate an ordered list with the possible combinations of values with length.

Each time the generator is called it will output a list of length :param length which contains a combinations of the elements in the list of values.

Parameters
  • values (List) – elements to combine

  • length (int) – size of the output

Returns

A generator which outputs ordered combinations of value as a list of size length

Return type

Generator

Examples

>>> for value in combine([1, 2], 2):
...     print(value)
[1, 1]
[2, 1]
[1, 2]
[2, 2]