Macaulay2 » Documentation
Packages » Macaulay2Doc » The Macaulay2 language » lists and sequences » reverse
next | previous | forward | backward | up | index | toc

# reverse -- reverse a list, sequence, or string

- Usage:
    `reverse(L)`
- Inputs:
  - L, a basic list or a string,
- Outputs:
  - R, a basic list or a string, containing the elements of L in reverse order

## Description

The output will be the same type as the input.

    i1 : reverse {5, 7, 2, 8}

    o1 = {8, 2, 7, 5}

    o1 : List

    i2 : reverse (5, 7, 2, 8)

    o2 = (8, 2, 7, 5)

    o2 : Sequence

    i3 : reverse "Hello, world!"

    o3 = !dlrow ,olleH

## See also

- sort -- sort a list or columns of a matrix

## Ways to use reverse:

- `reverse(BasicList)`
- `reverse(String)`

## For the programmer

The object reverse is a compiled function.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Macaulay2Doc/functions/reverse-doc.m2:28:0.