zigzag_product

zigzag_product(*iterables, iterator_lengths=None, return_index=False): 

LLM Docstring

Enumerate a Cartesian product while reversing selected axes to create a serpentine order.

Inputs are materialized, optionally taking only the supplied iterator_lengths. As the ordinary multi-index advances, axis-direction flags are toggled when trailing indices reset to zero.

  • iterables: collections.abc.Iterable

    Input iterables forming the Cartesian product.

  • iterator_lengths: collections.abc.Iterable[int | None] | None

    Optional lengths used both to limit materialization and reflect indices.

  • return_index: bool

    Whether to yield each value tuple together with its selected index tuple.

  • :returns: collections.abc.Iterator

    Iterator over value tuples or (values, indices) pairs.


Feedback

Examples

Templates

Documentation