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

apply_predicate

def apply_predicate[predicate: def(IntTuple, IntTuple) thin -> Bool](a: IntTuple, b: IntTuple) -> Bool

Apply a predicate function recursively to two IntTuples.

This function traverses two IntTuples with the same structure and applies a predicate function to corresponding elements. The predicate is applied only to the leaf nodes (integer values).

Note: If the structures of the two IntTuples don't match (different nesting or length), the function returns False without applying the predicate.

Parameters:

  • โ€‹predicate (def(IntTuple, IntTuple) thin -> Bool): A function that takes two IntTuples (containing integer values) and returns a boolean result.

Args:

  • โ€‹a (IntTuple): First IntTuple to compare.
  • โ€‹b (IntTuple): Second IntTuple to compare.

Returns:

Bool: True if the predicate returns True for all corresponding elements and the structures match, False otherwise.

Was this page helpful?