For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).
zip
zip[*Ts: Iterable](*iterables: *Ts.values, out res: _ZipIterator[iterables.origin, *#kgen.param_list.tabulate(TypeList[Ts.values], [idx: __mlir_type.index] Ts.values[idx].IteratorType[False, iterables.origin._mlir_origin, iterables.origin])]) where TypeList.all_satisfies[comptime[Type: AnyType] conforms_to(Type, AnyType & ImplicitlyDestructible)]()
Returns an iterator that yields tuples of the elements of the original iterables.
Examples:
var l = ["hey", "hi", "hello"]
var l2 = [10, 20, 30]
for a, b in zip(l, l2):
print(a, b)
Parameters:
- *Ts (
Iterable): The type of the iterables.
Args:
- *iterables (
*Ts.values): The iterables.
Returns:
_ZipIterator[iterables.origin, *#kgen.param_list.tabulate(TypeList[Ts.values], [idx: __mlir_type.index] Ts.values[idx].IteratorType[False, iterables.origin._mlir_origin, iterables.origin])]: A zip iterator that yields tuples of elements from all iterables.
zip[*Ts: IterableOwned](var *iterables: *Ts.values, out res: _ZipIterator[MutExternalOrigin, *#kgen.param_list.tabulate(TypeList[Ts.values], [idx: __mlir_type.index] Ts.values[idx].IteratorOwnedType)]) where TypeList.all_satisfies[comptime[Type: AnyType] conforms_to(Type, AnyType & ImplicitlyDestructible)]()
Returns an iterator that yields tuples of the elements of the original iterables.
Examples:
for a, b in zip(["hey", "hi", "hello"], [10, 20, 30]):
print(a, b)
Parameters:
- *Ts (
IterableOwned): The type of the iterables.
Args:
- *iterables (
*Ts.values): The iterables.
Returns:
_ZipIterator[MutExternalOrigin, *#kgen.param_list.tabulate(TypeList[Ts.values], [idx: __mlir_type.index] Ts.values[idx].IteratorOwnedType)]: A zip iterator that yields tuples of elements from all iterables.