>  Docs Center  >  IDL Reference  >  Array Manipulation  >  REVERSE

REVERSE

REVERSE

The REVERSE function reverses the order of one dimension of an array.

Tip: To reverse a string use the IDL_String.Reverse method.

Examples


Reverse the order of an array where each element is set to the value of its subscript:

; Create an array:
A = [[0,1,2],[3,4,5],[6,7,8]]
; Print the array:
PRINT, 'Original Array:'
PRINT, A
; Reverse the columns of A.
PRINT, 'Reversed Columns:'
PRINT, REVERSE(A)
; Reverse the rows of A:
PRINT, 'Reversed Rows:'
PRINT, REVERSE(A, 2)

IDL prints:

Original Array:
       0       1       2
       3       4       5
       6       7       8
Reversed Columns:
       2       1       0
       5       4       3
       8       7       6
Reversed Rows:
       6       7       8
       3       4       5
       0       1       2

Syntax


Result = REVERSE( Array [, Subscript_Index] [, /OVERWRITE] )

Return Value


Returns the reversed dimension of the array.

Arguments


Array

The array containing the original data.

Subscript_Index

An integer specifying the dimension index (1, 2, 3, etc.) that will be reversed. If this argument is omitted, the first dimension is reversed.

If this index is greater than the number of dimensions of Array, that dimension is treated as being of size 1 and a copy of Array is returned. Since IDL does not support greater than 8 dimensional arrays, this index must be in the range [1, 8].

If this index is negative, the dimension to reverse is counted from the last forward. A value of -1 implies the last dimension, -2 the next to last, etc. The magnitude of the index must be less than or equal to the number of dimensions of Array.

This argument is ignored for scalar input.

Keywords


OVERWRITE

Set this keyword to conserve memory by doing the transformation “in-place.” The result overwrites the previous contents of the Array parameter.

This keyword is ignored for scalar input.

Version History


Original

Introduced

See Also


INVERT, REFORM, ROT, ROTATE, SHIFT, TRANSPOSE



© 2020 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us