listtools.zip_cyclic

abjad.tools.listtools.zip_cyclic(*iterables)

Like Python zip(), but return a list of length equal to the iterable of greatest length in iterables and cycle over the elements of the iterables of shorter length.

abjad> listtools.zip_cyclic([1, 2, 3], ['a', 'b'])
[(1, 'a'), (2, 'b'), (3, 'a')]

New in version 1.1.1: Arbitrary number of input iterables now allowed.

abjad> a = [10, 11, 12]
abjad> b = [20, 21]
abjad> c = [30, 31, 32, 33]
abjad> listtools.zip_cyclic(a, b, c)
[(10, 20, 30), (11, 21, 31), (12, 20, 32), (10, 21, 33)]

Previous topic

listtools.weight

Next topic

listtools.zip_nontruncating

This Page