Skip to main content

Mojo function

shallow_apply

shallow_apply[func: fn[?, origin: ImmutableOrigin](IntTuple[origin]) -> Int](t: IntTuple[origin]) -> IntTuple`

Apply a function to each top-level element of an IntTuple.

Unlike apply(), this function only operates on the immediate children of the input tuple without recursing into nested tuples.

Parameters:

  • func (fn[?, origin: ImmutableOrigin](IntTuple[origin]) -> Int): Function that takes an IntTupleand returns anInt`.

Args:

  • t (IntTuple): The IntTuple whose elements will be transformed.

Returns:

IntTuple: A new IntTuple with the function applied to each top-level element.

Was this page helpful?