**S-Lang** includes many intrinsic functions that operate on arrays. The
additional functions described here are defined in
`arrayfuns.sl`

.

**Synopsis**-
Rearrange the elements of a 1-d array or list.

**Usage**-
`rearrange (A, indices)`

**Description**-
This function performs an in-place rearrangment of the the elements of an array according to the specified permutation, represented by the

`indices`

argument. The`indices`

array is assumed to contain unique integers in the range`[0,length(A)-1]`

. **Notes**-
The function modifies the elements of the

`indices`

array while it performs the rearrangement. The values will get restored upon return from function.The algorithm used was derived from the DPPERM function, which is part of the SLATEC package. See http://gams.nist.gov/cgi-bin/serve.cgi/Package/SLATEC.

**See Also**-
`array_reverse, array_swap`

**Synopsis**-
Reverse the elements of a 1-d array

**Usage**-
`Array_Type reverse (Array_Type A)`

**Description**-
The

`reverse`

function reverses the elements of a 1-d array and returns the result. **See Also**-
`shift`

**Synopsis**-
Shift the elements of a 1-d array

**Usage**-
`Array_Type shift (Array_Type A, Int_Type n)`

**Description**-
The

`shift`

function shifts the elements of an array by a specified amount and returns the result. If`n`

is positive, the ith element of the array will be shifted to the position`i-n`

of the array. Elements for which`i-n`

is less than 0 will be moved to the end of the array. **Example**-
A = [1,2,3,4,5,6,7,8,9]; B = shift (A, 3); % ==> B = [4,5,6,7,8,9,1,2,3]; C = shift (A, -1); % ==> C = [9,1,2,3,4,5,6,7,8];

**Notes**-
It many ways

`rotate`

would be a better name for this function. **See Also**-
`reverse, transpose`

Next Previous Contents