swapped

fun <T> List<T>.swapped(i: Int, j: Int): List<T>

Returns a copy of this list with the elements at i and j exchanged.

The receiver is not modified.

Throws

if i or j is not a valid index.