Given an array of positive integers and two distinct valid indices, return the array with the two elements corresponding to the two indices swapped.
You may choose to use 0-indexing or 1-indexing, but the testcases below will be 0-indexed.
array m n output
[1,2,3,4] 0 1 [2,1,3,4]
[5,8,9] 0 2 [9,8,5]
[11,13,15,3] 1 2 [11,15,13,3]
[11,13,15,3] 2 1 [11,15,13,3]
[11,15,15,3] 2 1 [11,15,15,3]
This is code-golf. Shortest answer in bytes wins. Standard loopholes apply.
m
andn
be taken as an array? \$\endgroup\$