Skip to main content
Log in

Mojo function

reverse

reverse(src: IntTuple[origin]) -> IntTuple

Reverses the order of elements in an IntTuple, recursively.

This function reverses the top-level elements of the IntTuple and recursively reverses any nested IntTuples.

Example:

```mojo
from layout import IntTuple
var t = IntTuple(1, 2, (3, 4))
var reversed = reverse(t) # returns ((4, 3), 2, 1)
```
.
```mojo
from layout import IntTuple
var t = IntTuple(1, 2, (3, 4))
var reversed = reverse(t) # returns ((4, 3), 2, 1)
```
.

Args:

  • src (IntTuple[origin]): The source IntTuple to reverse.

Returns:

A new IntTuple with elements in reversed order.