Mojo function
apply_predicate
apply_predicate[predicate: fn[ImmutableOrigin, ImmutableOrigin](IntTuple[$0], IntTuple[$1]) -> Bool](a: IntTuple[origin], b: IntTuple[origin]) -> Bool
Apply a predicate function recursively to two IntTuple
s.
This function traverses two IntTuple
s 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 IntTuple
s don't match (different nesting or length),
the function returns False without applying the predicate.
Parameters:
- predicate (
fn[ImmutableOrigin, ImmutableOrigin](IntTuple[$0], IntTuple[$1]) -> Bool
): A function that takes twoIntTuple
s (containing integer values) and returns a boolean result.
Args:
- a (
IntTuple[origin]
): FirstIntTuple
to compare. - b (
IntTuple[origin]
): SecondIntTuple
to compare.
Returns:
True if the predicate returns True for all corresponding elements and the structures match, False otherwise.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!