swapAt method
New list with elements at i and j swapped; in range only.
Implementation
@useResult
List<T> swapAt(int i, int j) {
final List<T> out = List<T>.of(this);
if (i >= 0 && i < length && j >= 0 && j < length) {
final T tmp = out[i];
out[i] = out[j];
out[j] = tmp;
}
return out;
}