Mojo function
to_nest
to_nest(nested: IntTuple[origin], flat: IntTuple[origin]) -> IntTuple
Nests a flat IntTuple according to the structure of a nested IntTuple.
This function reshapes a flat sequence of values into a hierarchical structure
that matches the pattern of a template nested IntTuple.
Example:
from layout import IntTuple
from layout.int_tuple import to_nest
var result = to_nest(IntTuple(2, IntTuple(3, 4), 5), IntTuple(1, 2, 3, 4))
# returns IntTuple(1, (2, 3), 4)Args:
- nested (
IntTuple): The templateIntTupledefining the desired structure. - flat (
IntTuple): The flatIntTuplecontaining the values to be nested.
Returns:
IntTuple: A new IntTuple with the values from flat arranged in the structure of nested.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!