Mwnci swap() Function

Syntax

swap(array,integer,integer,)

Description

The swap() function returns a new array, with the values of the given indexes swapped. If an index is not withing the length of the array, an error is returned.

Example

a=[1,2,3,4,5]
b=swap(a, 0, 3)
println(b)


[4, 2, 3, 1, 5]