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

depth

def depth(src: IntTuple) -> Int

Calculates the maximum nesting depth of an IntTuple.

This function recursively traverses the IntTuple structure to determine its maximum nesting depth. A scalar value has depth 0, a flat tuple has depth 1, and nested tuples increase the depth accordingly.

Example:

from layout import IntTuple, depth

print(depth(IntTuple(1))) # prints 0
print(depth(IntTuple(1, 2))) # prints 1
print(depth((IntTuple(1, 2)))) # prints 2

Args:

  • src (IntTuple): The IntTuple to measure the depth of.

Returns:

Int: An integer representing the maximum nesting depth.

Was this page helpful?