Skip to main content
Log in

Mojo function

apply_zip

apply_zip[func: fn[ImmutableOrigin, ImmutableOrigin](IntTuple[$0], IntTuple[$1]) -> IntTuple](t1: IntTuple[origin], t2: IntTuple[origin]) -> IntTuple

Apply a function to pairs of elements from two IntTuples.

This function zips two IntTuples together and applies the given function to each pair of elements, creating a new IntTuple with the results.

Parameters:

  • func (fn[ImmutableOrigin, ImmutableOrigin](IntTuple[$0], IntTuple[$1]) -> IntTuple): Function that takes two IntTuples and returns an IntTuple.

Args:

  • t1 (IntTuple[origin]): First IntTuple.
  • t2 (IntTuple[origin]): Second IntTuple.

Returns:

A new IntTuple containing the results of applying func to each pair.

apply_zip[: origin.set, //, func: fn[ImmutableOrigin, ImmutableOrigin](IntTuple[$0], IntTuple[$1]) capturing -> IntTuple](t1: IntTuple[origin], t2: IntTuple[origin]) -> IntTuple

Apply a capturing function to pairs of elements from two IntTuples.

This overload allows the function to capture variables from its environment.

Parameters:

  • func (fn[ImmutableOrigin, ImmutableOrigin](IntTuple[$0], IntTuple[$1]) capturing -> IntTuple): Capturing function that takes two IntTuples and returns an IntTuple.

Args:

  • t1 (IntTuple[origin]): First IntTuple.
  • t2 (IntTuple[origin]): Second IntTuple.

Returns:

A new IntTuple containing the results of applying func to each pair.

apply_zip[func: fn[ImmutableOrigin, ImmutableOrigin, ImmutableOrigin](IntTuple[$0], IntTuple[$1], IntTuple[$2]) -> IntTuple](t1: IntTuple[origin], t2: IntTuple[origin], t3: IntTuple[origin]) -> IntTuple

Apply a function to triplets of elements from three IntTuples.

This function zips three IntTuples together and applies the given function to each triplet of elements, creating a new IntTuple with the results.

Parameters:

  • func (fn[ImmutableOrigin, ImmutableOrigin, ImmutableOrigin](IntTuple[$0], IntTuple[$1], IntTuple[$2]) -> IntTuple): Function that takes three IntTuples and returns an IntTuple.

Args:

  • t1 (IntTuple[origin]): First IntTuple.
  • t2 (IntTuple[origin]): Second IntTuple.
  • t3 (IntTuple[origin]): Third IntTuple.

Returns:

A new IntTuple containing the results of applying func to each triplet.

apply_zip[: origin.set, //, func: fn[ImmutableOrigin, ImmutableOrigin, ImmutableOrigin](IntTuple[$0], IntTuple[$1], IntTuple[$2]) capturing -> IntTuple](t1: IntTuple[origin], t2: IntTuple[origin], t3: IntTuple[origin]) -> IntTuple

Apply a capturing function to triplets of elements from three IntTuples.

This overload allows the function to capture variables from its environment.

Parameters:

  • func (fn[ImmutableOrigin, ImmutableOrigin, ImmutableOrigin](IntTuple[$0], IntTuple[$1], IntTuple[$2]) capturing -> IntTuple): Capturing function that takes three IntTuples and returns an IntTuple.

Args:

  • t1 (IntTuple[origin]): First IntTuple.
  • t2 (IntTuple[origin]): Second IntTuple.
  • t3 (IntTuple[origin]): Third IntTuple.

Returns:

A new IntTuple containing the results of applying func to each triplet.