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:
```mojo
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)
```
.
```mojo
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[origin]
): The templateIntTuple
defining the desired structure. - flat (
IntTuple[origin]
): The flatIntTuple
containing the values to be nested.
Returns:
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!