Reverse

Reverse[expr]

reverses the order of the elements in expr.

Reverse[expr,n]

reverses elements at level n in expr.

Reverse[expr,{n1,n2,}]

reverses elements at levels n1, n2, in expr.

Details

  • Reverse works on SparseArray objects, reversing the elements in the corresponding ordinary array.
  • Reverse[expr] is equivalent to Reverse[expr,1].
  • For a matrix m, Reverse[m] reverses the order of the rows, and Reverse[m,2] reverses the order of the columns.

Examples

open allclose all

Basic Examples  (3)

In[1]:=
Click for copyable input
Out[1]=

Reverse an Association:

In[1]:=
Click for copyable input
Out[1]=

Reverse an Association on the first and second levels:

In[1]:=
Click for copyable input
Out[1]=

Generalizations & Extensions  (1)

Applications  (3)

Properties & Relations  (1)

See Also

Permutations  RotateLeft  RotateRight  StringReverse  IntegerReverse  PalindromeQ  Transpose  ImageReflect  ReverseSort

Tutorials

Introduced in 1988
(1.0)
| Updated in 2007
(6.0)