IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Mojo function

to_nest

def to_nest(nested: IntTuple, flat: IntTuple) -> 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 template IntTuple defining the desired structure.
  • flat (IntTuple): The flat IntTuple containing 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?