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
reduce
def reduce[FuncType: def(a: Int, b: IntTuple) -> Int](t: IntTuple, initializer: Int, reducer: FuncType) -> Int
Apply a reduction function to an IntTuple with an initial value.
This function iterates through each element of the IntTuple and applies
the provided reduction function cumulatively, starting with the initializer.
Parameters:
- βFuncType (
def(a: Int, b: IntTuple) -> Int): The reduction function type.
Args:
- βt (
IntTuple): TheIntTupleto reduce. - βinitializer (
Int): The initial value for the reduction operation. - βreducer (
FuncType): A function that combines the accumulated result with the next element.
Returns:
Int: The final accumulated result after applying the reduction function
to all elements in the IntTuple.