[Question]
  [
## Introduction:
Although we have a lot of challenges where swapping two items in a list is a subtask, like [Single swaps of an array](https://codegolf.stackexchange.com/q/152283/52210); [Swap to Sort an Array](https://codegolf.stackexchange.com/q/197536/52210); [\$n\$ swaps into a nop](https://codegolf.stackexchange.com/q/235710/52210); etc., we don't have the simple challenge of just swapping two items given a list and two indices.
**Input:**  
A list with some positive integers \$L\$, and two indices \$a\$ and \$b\$.
**Output:**  
The same list, with the two items at the given indices swapped.
## Challenge rules:
* The input-list is guaranteed to contain at least two items.
* The input-list is guaranteed to only contain positive integers.
* The input-indices can be either 0-based or 1-based (please specify in your answer which of the two you've used).
* The input-indices are guaranteed to be valid indices based on the length of the input-list.
* The input-indices are distinct, so will never be the same index. (The values in the input-list won't necessarily be distinct.)
* You can assume \$a<b\$ (and you're allowed to take the inputs in reversed order if it helps).
* I/O is flexible. You're allowed to take the input as a list/array/stream, from STDIN, as a delimited string, etc. You're allowed to modify the input-list directly, or return a new one with the two items swapped.
## General rules:
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer in bytes wins.  
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
* [Standard rules apply](https://codegolf.meta.stackexchange.com/questions/2419/default-for-code-golf-program-function-or-snippet/2422#2422) for your answer with [default I/O rules](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods/), so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
* [Default Loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden.
* If possible, please add a link with a test for your code (e.g. [TIO](https://tio.run/#)).
* Also, adding an explanation for your answer is highly recommended.
## Test cases
All test cases use 0-based indices.
```
Inputs: L=[1,2,3,4,5,6,7,8,9,10], a=3, b=7
Output:   [1,2,3,8,5,6,7,4,9,10]
Inputs: L=[ 3, 8, 1, 4,10,10,10,10], a=0, b=5
Output:   [10, 8, 1, 4,10, 3,10,10]
Inputs: L=[5,1,4,2,3], a=0, b=4
Output:   [3,1,4,2,5]
Inputs: L=[5,6], a=0, b=1
Output:   [6,5]
Inputs: L=[2,2,2], a=0, b=1
Output:   [2,2,2]
```
  
[Answer]
# Java, 27 bytes
```
java.util.Collections::swap
```
[Try it online!](https://tio.run/##ZU/BTsMwDL33K3xMJRMxBgzWDQkhTUKC046IQ@iSKl2aVrE7NE399pKugyF4F8vPfs/Ppdqpi3Kz7W3V1IGhjL1s2Tr5Yomz5B/9GILaU5Y07YezOeROEcGrsh4OCURYzzoYlWtYHXa13YARg9PiOfKFDg/gYofDGtixlGnWHaUnS2LFsRzFVTQWaw7WF2/voEJB6XhmwArMsj8ne6qd0znb2tN8Tp@q6b8Xsx/JnyiwhPEfqWgYiQle4RSv8QZvcYZ3eI@Ty/QsN9IIhzBFmP1i13tiXcm6ZdnEpOy8cKdxl3T9Fw)
[Answer]
# [Python 2](https://docs.python.org/2/), 32 bytes
```
def f(a,b,l):l[a],l[b]=l[b],l[a]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m728oLIkIz_PaMGCpaUlaboWNxVSUtMU0jQSdZJ0cjStcqITY3VyopNibUGEDogLVaeWY5uZV1BaoqHJlaYBZenA6BxNroKizLwShRyI6gU7o411LHQMdUx0DA3gKJbLgMsUogAA)
Mutates the input in-place.
---
26 bytes with a [NumPy](https://numpy.org) array:
```
def f(l,a):l[a[::-1]]=l[a]
```
[Try it online!](https://tio.run/##PYtLCgMhEAX3fQqXCh0YJwkEYU4ivRAmEsFP0zgLT28@DIGCqrd4PPqr1XXO/RlV1BmDcdkH79zFEm2fpBmlFVWPwkOlwk26CiJhQN5@1qny0bUx8P37c@FpMsCSald5@is@0OIN7fKHYIE7vAE "Python 2 – Try It Online")
[Answer]
# [Brain-Flak](https://github.com/Flakheads/BrainHack), 122 bytes
```
(([{}]{()<({}[()]<({}<>)<>>)>}{})<(({}({}))([{}]{})<{({}()<<>({}<>)>)}{}>)>())<>({}<<>{({}[()]<({}<>)<>>)}{}>){<>({}<>)}{}
```
[Try it online!](https://tio.run/##ZYw7CoBADAWvk1f6K4SQiyxbqI0iWNiGPfsz62IlBIYMk6z3clz7sp2kSPKSXaDiJQlypRrUDFa8hA8RA7QyjFcDVWupIbqAAE2p@f/Z2/h3ExvJniNndsGBE6cH "Brain-Flak (BrainHack) – Try It Online")
# Works with all integers, 138 bytes
```
(([{}]{()<({}[()]<({}<>)<>>)>}{})<(({}({}))([{}]{})<{({}()<<>({}<>)>)}{}>)>())<>({}<<>{({}[()]<({}<>)<>>)}{}>)<>([]){({}[()]<({}<>)<>>)}<>
```
[Try it online!](https://tio.run/##bYw7CoBADESvkyn9FULIRZYt1EYRLGzDnj3OuqVCYIY3j6z3clz7sp0RIslLdoGKlyTINdWgZrDihZyABzSTxCuBqjXVQI8hQENq/n32OtxTxt@qFhF9jDFHxxzYpgc "Brain-Flak (BrainHack) – Try It Online")
The difference here is that while the first uses
```
{<>({}<>)}{}
```
To pull all the items from the off stack onto the on stack this one has to use
```
<>({}){({}[()]<({}<>)<>>)}<>
```
The first one pulls until it hits a zero and then stops, so this will fail to produce the correct result when there is a zero before the first swapped value. The second checks the height and pulls that many times, thus it will work for any list.
[Answer]
# [R](https://www.r-project.org/), 31 bytes
Or **[R](https://www.r-project.org/)>=4.1, 24 bytes** by replacing the word `function` with `\`.
```
function(L,A){L[A]=L[rev(A)];L}
```
[Try it online!](https://tio.run/##fYuxCsIwFEX3fsUDlxd8Q5M0VSoZsgf8gJBBgwGXKiVxEb891lJLQRDucOGcM5SoS8x9SNdbj5YMe1pnvLZuuDzQMH@wrxKRd7ymgJJ2bMtZFfHzYU/ACRoa2XeMIOBJ1wRnrRZXEaeGBMk1bia8OeZ0z6kDACdnTflqztp1wH@CdlHFmIn/8qT48gY "R – Try It Online")
Takes input as a vector and a vector of two `1`-based indices.
[Answer]
# [Rust](https://www.rust-lang.org/), 11 bytes
```
<[_]>::swap
```
Modify the input in-place.
[Try it online!](https://tio.run/##HcpLCoMwAEXReVbxdFAivEHtzzax7UJEihQDQgyisQ7EtaeS6bl3nCcfjEPfdE5mq7Cth8EToaw@9UupaWmGoCP3s4fd06/9JlVOnIgzcSGuxI0oiDvxIPJjrYWRh/jHp8i0GMbOeesSma7qvaWE3XELfw "Rust – Try It Online")
[Answer]
# [Factor](https://factorcode.org/), 21 bytes
```
[ [ exchange ] keep ]
```
[Try it online!](https://tio.run/##Dcw9DoIwAIbhnVO8JzAiKqgHMC4uxokwNM3nT2xKLSXBGM9eGZ/luRmb@pivl9P5uGfQe5S3GngpejlCVEqfEJ8@cSiKipovJSsq1mzYzm7YUS755ZYWTfZh/F1086BAl61xjkX@Aw "Factor – Try It Online")
It's almost a built-in, but `exchange` has stack effect `( m n seq -- )` so we need `keep` to actually keep the sequence around on the data stack. 0-indexed.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~7~~ 5 bytes
```
œPżịF
```
[Try it online!](https://tio.run/##y0rNyan8///o5ICjex7u7nb7H/qoYcbh5UpHJz3cOeNR05rI//@jjXUUzGN1FKINdBRMobQJlDaE0/@jDXWMdIx1THRMdcx0zHUsdCx1DA1A0gpA/RZAJUBdQBE4AkmZ6hgCNQC1QThmIMoIyDeKBQA "Jelly – Try It Online")
Takes indexes as 1 indexed and reversed (so `[b, a]`), the Footer on TIO does this for you.
## How it works
```
œPżịF - Main link. Takes indices I on the left, array A on the right
œP    - Partition A at the indices in I, not keeping the borders
   ị  - Retrieve the elements of A at the indices in I; [A[b], A[a]]
  ż   - Zip together
    F - Flatten
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 5 [bytes](https://github.com/abrudz/SBCS)
1-indexed. Reverse the sublist at the indices given by the second input of the first input.
```
⌽@⎕⊢⎕
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qKM97f@jnr0Oj/qmPupaBCRBQv/TuB71blYwNOAyUbDgSuMyVrBQMFQwAQrAEZehghkA "APL (Dyalog Unicode) – Try It Online")
[Answer]
# Lean, ~~211~~ 205 bytes
Helper:
```
notation `L`:=list ℕ
structure R:=m::(A:L)(B:ℕ)(C:L)
def r:L->L->ℕ->R
|p(h::t)0:=R.m p h t
|p(h::t)(n+1):=r(p++[h])t n
|_[]_:=R.m[]0[]
```
Actual function:
```
λl a b,let f:=r[]l a,z:=r[]f.C(b-a-1)in f.A++z.B::z.A++f.B::z.C
```
[Try it online!](https://leanprover-community.github.io/lean-web-editor/#code=import%20data.list.basic%0Aimport%20data.nat.basic%0A%0Anotation%20%60L%60%3A%3Dlist%20%E2%84%95%0Astructure%20R%3A%3Dm%3A%3A%28A%3AL%29%28B%3A%E2%84%95%29%28C%3AL%29%0Adef%20r%3AL-%3EL-%3E%E2%84%95-%3ER%0A%7Cp%28h%3A%3At%290%3A%3DR.m%20p%20h%20t%0A%7Cp%28h%3A%3At%29%28n%2B1%29%3A%3Dr%28p%2B%2B%5Bh%5D%29t%20n%0A%7C_%5B%5D_%3A%3DR.m%5B%5D0%5B%5D%0Adef%20s%20%3A%20list%20%E2%84%95%20-%3E%20%E2%84%95%20-%3E%20%E2%84%95%20-%3E%20list%20%E2%84%95%20%3A%3D%0A%CE%BBl%20a%20b%2Clet%20f%3A%3Dr%5B%5Dl%20a%2Cz%3A%3Dr%5B%5Df.C%28b-a-1%29in%20f.A%2B%2Bz.B%3A%3Az.A%2B%2Bf.B%3A%3Az.C%0A%0A%23eval%20s%20%5B1%2C2%2C3%2C4%2C5%2C6%2C7%2C8%2C9%2C10%5D%203%207%0A--%5B1%2C2%2C3%2C8%2C5%2C6%2C7%2C4%2C9%2C10%5D%0A%0A%23eval%20s%20%5B%203%2C%208%2C%201%2C%204%2C10%2C10%2C10%2C10%5D%200%205%0A--%5B10%2C%208%2C%201%2C%204%2C10%2C%203%2C10%2C10%5D%0A%0A%23eval%20s%20%5B5%2C1%2C4%2C2%2C3%5D%200%204%0A--%5B3%2C1%2C4%2C2%2C5%5D%0A%0A%23eval%20s%20%5B5%2C6%5D%200%201%0A--%5B6%2C5%5D%0A%0A%23eval%20s%20%5B2%2C2%2C2%5D%200%201%0A--%5B2%2C2%2C2%5D)
There's got to be a way to make product types and define type aliases easily, but I couldn't find it.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jellylanguage), 7 bytes
```
,U$yJ}ị
```
[Try It Online!](https://jht.hyper-neutrino.xyz/tio#WyIiLCIsVSR5Sn3hu4siLCIiLCIiLFsiMSwgNiIsIlsgMywgOCwgMSwgNCwxMCwxMCwxMCwxMF0iXV0=)
A totally different Jelly 7-byter, so I figured I'd post this too. This is 1-indexed.
```
,U$yJ}ị    Main link; take indices on the left
,U$        Pair the indices with the reverse of itself ([[a, b], [b, a]])
   y       Apply this as a translation to
    J}     The indices of the right list (J takes a list of length L and returns [1, 2, ..., L])
      ị    Index back into the original list
```
[Answer]
# [Haskell](https://www.haskell.org/), 56 bytes
```
(?)=splitAt
(x!y)z|(q,d:e)<-y?z,(a,b:c)<-x?q=a++d:c++b:e
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/X8Ne07a4ICezxLGES6NCsVKzqkajUCfFKlXTRrfSvkpHI1EnySoZyKmwL7RN1NZOsUrW1k6ySv2fm5iZZ5uSz6VQUJSZV6JiqGikEm2oY6RjrGMSCxM0UDQGCurpGRrE/gcA "Haskell – Try It Online")
`splitAt` breaks the list into two parts at the particular index. This is useful because unlike `(!!)` we can get all the parts first.
To start we split at the second element, then the first. Splitting at the second first means we don't have to do extra arithmetic do calculate the offset which is required if we split at the first.
We use a pattern match to then get the first element of various pieces.
[Answer]
# [Julia 1.0](http://julialang.org/), 20 bytes
```
L*i=L[i]=L[i[[2,1]]]
```
[Try it online!](https://tio.run/##jY5NbsMgEIX3nGKWkI4i4784C25AT4BYEGWkUiHLcpw2t3fHxknkXRFC8973HvB9TzHoxzzbQzTWRb8czpWovffz71dMBNN4JwG8LAa8gAH6CUl@0hSOQxhvJEcK1xR7kkqpNUiP4T@xt7HK8GH0OlyewzDGfkq9lOvLW8seHAu/C1i1l2DM8gklqL/OTmOJFdbYYIsn7PCMuvAIFcJJbLDbYJ2hEG7BHYJGqNl5be4VCA33ih3neOZcbVDzRXxtDtfCVZvTZNxmoIVrs1UyK19mVn8 "Julia 1.0 – Try It Online")
1-indexed
expects `L*[a,b]` and mutates `L`
[Answer]
# JavaScript, 31 bytes
```
l=>a=>b=>l[a]^=l[b]^(l[b]=l[a])
```
Only works for integers.
[Try it online!](https://tio.run/##FYlNCoAgFAb3nUThC/rXFs@LiMIzEAqJKPH6VpuBmTm48LPd@5XbomukmsgwmUAmWXaekg3Oi5/0B/l922PAiAkzFihorOg7B6YRgVQTRZKCpQiyue79zJ/WFw)
*Thanks to [Arnauld](https://codegolf.stackexchange.com/users/58563).*
# JavaScript, 32 bytes
```
l=>a=>b=>[l[a],l[b]]=[l[b],l[a]]
```
[Try it online!](https://tio.run/##FYpLCoAwEMX2nqSFJ/j/LKYXGWYxFQSlSKnS61ddhYScmvXe0hGfOi9lpxLIKTlPjgOrILAXIf6BP8g3cIsOPQaMmDBjwYq2ESj18DRXuwnWqDXeVjEd1/NpeQE)
[Answer]
# [stacked](https://github.com/ConorOBrien-Foxx/stacked), 5 bytes
```
$exch
```
[Try it online!](https://tio.run/##Ky5JTM5OTfn/XyW1Ijnjv4NVGheXhoaGoYKRgrGCiYKpgpmCuYKFgqWCoYGmAlDIXJNLQUPDGChkCJQ2NIAjoKyCgYIpWNoULAk0ASSIAAYKJlBpM1QJmLQhWNoIqNNIE6u0JhdXtJ6eXlqsQm5igUJ@acl/AA "Stacked – Try It Online")
You can remove the `$` if input is allowed to be taken from the stack for 4 bytes. Convenient builtin to be sure.
## [22 bytes](https://tio.run/##bczLCsIwEIXhfZ7iLJNNyKRNq67yHiGLoBZab4FWxKePY/CC4DCr/2NmXtL2sN@VEvzkxzBiwnm@pRxTzsd7LH4zCCGlJFg0aOHQoccKa5BR4NQrASkbTsRM5rOsMHCVXUX@8IzfMWhf3P3Cm6my5Uur/rISImith4hTyrhcl/IA "Stacked – Try It Online")
```
[@j@i[i j nswap]apply]
```
Function. `nswap` performs a stack operation of swapping the `i`th and `j`th members, so we simply pop `i` and `j` and treat the stack at the top of the stack *as* the stack for `nswap`.
[Answer]
# Kotlin, 34 bytes
```
{l,x,y->l[x]=l[y].also{l[y]=l[x]}}
```
Ungolfed:
```
{ l, x, y ->
    l[x] = l[y].also { l[y] = l[x] }
}
```
This answer is a bit of an idiom in Kotlin.
`Any#also()` basically executes the given function, but then returns the receiver. In this case, the outer `l[y]` is evaluated, then `.also()` runs the lambda `{ l[y] = l[x] }`, and returns the old value of `l[y]`.
[Try it online!](https://tio.run/##RU7BCsIwFLvvK96xhbfhnDoVu7ugePI0dqhgoeytFdfJRtm3120ezCEkIZDU1pE24SMJ1BHYtXPyQc@Lbt3pbFyBMPFCHOIC7kY7EMET9jjEBZV9JagcqkRSa/2sxJyNY1CdgUZqwzh4iGDCPEEgoPlP3BRLcY0ZbnCLO8xxjwdMV3zpK0YIGUL@s/VyNNE2eb21cYx4NIYv)
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 4 bytes
```
{e\}
```
Code block ([analogous to a function](https://codegolf.meta.stackexchange.com/a/2422/36398)) that pops three elements from the stack: `L`, `a`, `b`, and pushes the swapped version of `L`. Indices `a`, `b` are 0-based.
[**Try it online!**](https://tio.run/##S85KzP1fWPe/OjWm9n9dwf9oBWMFCwVDBRMFQwM4ilUwUDAFAA "CJam – Try It Online")
### Explanation
```
{  }  e# Define code block
 e\   e# Swap elements in array
```
*Header:*
```
q     e# Read all input as an unevaluated string, and push it to the stack
 ~    e# Evaluate string. Gives an array and two numbers, that are pushed
```
*Footer:*
```
~     e# Execute block
 p    e# Print string representation of the top of the stack
```
[Answer]
# [Zsh](https://www.zsh.org), 39 bytes
```
eval "t=$`<i`;`<i`=$`<j`;`<j`=$"t
<<<$@
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m724qjhjwZqM1MQUBV1Du0wuu6ylpSVpuhY31VPLEnMUlEpsVRJsMhOsQQSImQViZgGZSiVcNjY2Kg4Q5Qsg1MZoQx0jHWMdEx1THTMdcx2L2CXGXGZcEEkA)
Takes the array on the command line, with the two indices in files called `i` and `j`.
A bit of quote trickery to avoid escapes.
[Answer]
# [C (clang)](http://clang.llvm.org/), 34 bytes
```
f(*a,i,j){a[i]^=a[j]^(a[j]=a[i]);}
```
[Try it online!](https://tio.run/##rVPbbqMwFHzvVxwhpQLqaBNo2qQ0uw@r/QpCK0RMy6UkAqSNiPj1ZY8vgONQqQ9FwjaeOZcZm2ge5WHx1nWxaYckIal1Dv0keNmGfhq8mGzcsg3La7ukqOEjTArTgvMN4MM2alrVr0s/gC2c1wQ2BB4I3BN4JLBcEFjx1br1RrIjyILjDhQe5eCoct2Bu@Sgy8cN5z7wNaa@6CUXEVXS0ENsiu6sH/LTlt8EVNzRcEfDXQ13rbGmzYtWoqjITqRMObtag6@JIC@EJh1NBbri4lYKSk9HGtV035vN3FXdXutmDwGj4S4nfGL4wL8wfdOb7kybbg9xImpskygdKGt3QtPloY0pRuOVPaLTnAmacoZj5QnecJbRe1jaONIoo6Vox9id/ji70@Y3viuDgPrtGjIuPpRgMi1JsacnDFt4cvmsN3Bd3vLg7o6z@1@qdybHTOI6czjwVBQvnYSrKRgSieJVm4LTHk6v4GOJhNg0fMPSKjYY9BHm@SEy7@1cQQcDMiE@Q@E505WpmtjT@BnztcbJuwD6qrNqtkefs1/M7CcDRxai1GqvGg0IzPbshflP8DEiIZCq3ZnN1R5r9hhWFfay1FRS3Bvus27O15XK7Hy6vZXCMfO3KodZtSuQ2d9ZVk0NiUtKzUZutDdt9y@K8/Ct6uZ//wM "C (clang) – Try It Online")
*Port of [Unmitigated](https://codegolf.stackexchange.com/users/99986/unmitigated)'s [C++ answer](https://codegolf.stackexchange.com/a/236318/9481)*
[Answer]
# TI-Basic, ~~39~~ 33 bytes
```
Prompt L,A,B
ʟL(A→X
ʟL(B→ʟL(A
X→ʟL(B
ʟL
```
-6 bytes thanks to [MarcMush](https://codegolf.stackexchange.com/users/98541/marcmush).
Input indices are 1-based. Output is stored in `Ans` and is displayed.
[Answer]
# [ErrLess](https://sr.ht/%7Eruan_p/Errless/), 6 bytes
```
0m:r.M
```
A [macro](https://man.sr.ht/%7Eruan_p/errless_docs/reference.md#-procedures-amp-macros).
## Explanation
```
0 { Push a 0 to the stack to identify the macro } 
m { Start macro definition }
: { (L a b) -> (L (a b)) }
r { Rotate }
. { Halt (Return) }
M { End macro definition }
```
You can test it with the following program:
```
0m
 :r.
M
{ Test cases: }
1,2x3x4x5x6x7x8x9xax 3 7
0" # a? { Outputs "(1 2 3 8 5 6 7 4 9 10)" and a newline }
3,8x1x4xaxaxaxax 0 5
0" # a? { Outputs "(10 8 1 4 10 3 10 10)" and a newline }
5,1x4x2x3x 0 4
0" # a? { Outputs "(3 1 4 2 5)" and a newline }
5,6x 0 1
0" # a? { Outputs "(6 5)" and a newline }
2,2x2x 0 1
0" # a? { Outputs "(2 2 2)" and a newline }
.
```
[Try it online!](https://tio.run/##1VvpdtvGFf7Pp5jItQlIJEVK3kKbTh1v1Yltubba04ZieIbAkIQNAshgaJFynJ99gD5iX8S9dxZgsJCSHatJ5WNKGMzc@9117ixM1mIeR4d3E/7pGnnKhDdnPpnyeEHmQiRpf39/FohOyjtzsf8rX9JonOwzzkOWpmPOpum@4IztL2gQ7QeCLfYnwSyIxHgZBV7ss/1EkTdDOsmaUEEOu@TYE/GEcXLQPeg1gkUSc0EonyWUp8w8p@vU/CmCBWs0vJCmKQmipN8g8OOzKRmPgygQ47GTsnDqqnb8wceOTwUlA9JsNrL@MybCIGLl7pyJJY@sUXvIvZMKP4g6nFFfDnKH/XZvVCAmCbVIGpyzQbtnUQymspHcJ93@xeQdN4cCiLOOwz4SGd0ryJO/xZf9UVkKXiWPHdshixzuugX8QVkTEZsBi6c0BDtUIKHAvRzq2TwIGeGdIE0T6oF@cjLbhoFq4BXYpd3sa34nfMnuXcAnigXhQzBAzo/QyM/afHA9UcWwV0/TVqikgEozbQXJubK6a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Aba@Rb
```
Takes input as two command-line arguments: the list, and a list containing the two indices (0-based). [Attempt This Online!](https://ato.pxeger.com/run?1=m724ILNgebSSbkWBUuyCpaUlaboWKxKDHJMSHYKSIFyo6E3laKVoQ2sja2NrE2tTazNrc2sLa0trQ4NYJR0FpWhja_NYuAkA)
### Explanation
The `-x` flag is for taking the arguments as lists rather than strings; the `-p` flag is for displaying the result as a list rather than concatenated together.
```
a         ; In the first argument
 RA       ; replace the items at indices given by
   b      ; the second argument
    a     ; with the values in the first argument
     @    ; at indices
      Rb  ; reverse(second argument)
```
---
The straightforward version, which takes the indices as separate arguments, comes in at [9 bytes](https://ato.pxeger.com/run?1=m724ILNgebSSbkWBUuyCpaUlaboWKxMdkqysEh2SEyF8qPBNhWilaENrI2tjaxNrU2sza3NrC2tLa0ODWCUdBWMdBXOYfgA):
```
a@b::a@ca
   ::      ; Swap
a@b        ; the item in a at index b
     a@c   ; with the item in a at index c
        a  ; Output the new value of a
```
[Answer]
# [Python 2](https://docs.python.org/2/), 49 bytes
```
lambda a,b,c:a[:b]+[a[c]]+a[b+1:c]+[a[b]]+a[c+1:]
```
[Try it online!](https://tio.run/##Hcc7CoAwEAXAq6RU8grj34AnWbfYjYiCP8TG00dxujmfez72PE79EFfZdBQjUAQv5JUtCQVmK6TW@fBf/4fvHM9r2W8zJeSQo0CJCjUatOjgMoYpYJo0vg "Python 2 – Try It Online")
[Answer]
# [PHP](https://php.net/), 46 bytes
```
fn(&$a,$i,$j)=>[$a[$i],$a[$j]]=[$a[$j],$a[$i]]
```
[Try it online!](https://tio.run/##JY3BCsIwEETv@xU5LNLAHFqr1hKjHxIWSZHQFipBqr8ft/T0hjcDk8dcbo88ZuLkS3pXB47gCTxbfw8cA0@CDbOID3vArqU4Il6NN6HBES1OOOOCDlf0aGpxxFHLVjkou22dKl5h9MLwYB394uf5@i5ZrXXlDw "PHP – Try It Online")
changes the array in place, 0 indexing
My first shot was with `list`, but PHP has array destructuring since 7.1, so it ends up like the JS answer with lots of dollars (money money money!)
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 7 bytes
```
İṘZ(n÷Ȧ
```
[Try it Online!](https://lyxal.pythonanywhere.com?flags=&code=%C4%B0%E1%B9%98Z%28n%C3%B7%C8%A6&inputs=%5B3%2C7%5D%0A%5B1%2C2%2C3%2C4%2C5%2C6%2C7%2C8%2C9%2C10%5D&header=&footer=)
This could almost certainly be a bit smaller, but I got smol brain and can't think of a good way to swap values.
Explanation:
```
İ        # Get the values at the indexes
 Ṙ       # Reverse the values
  Z      # Zip the values with the new indexes
   (n    # For each value/index pair:
     ÷   #  Split the value/index
      Ȧ  #  Put the value at that index
```
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 99 bytes
```
2`\d+
$*
1*(,1*);
$1,$&
(?<=(?=.*;(?<-2>\d+,)*(\d+))(1)*,(?(4)$)(?<-4>1)*(,1*)?;(\d+,)*)\d+
$1
.*;
```
[Try it online!](https://tio.run/##PYyxDsIwDER3f0dAdjhQnKYtKLQZ@QmGItGBhQHx/8EECcnS@d75/Frfj@etbviy1Lhc7ztyntQz1Esmp3Bb4nKeuEwHn23bx9muIJ5NRFjFgwsncfJN02ygtUvm36G0r0rWp1o7jFkR0SGhx4ARR5yggQL63JlRCzT8x3jKfaNWMqfmhqbRSPwA "Retina 0.8.2 – Try It Online") Link includes test cases. Takes input in the form `a,b;L`. Explanation:
```
2`\d+
$*
```
Convert the indices to unary.
```
1*(,1*);
$1,$&
```
Make a second copy of `b` so that we now have `b,a,b;L`.
```
(?<=(?=.*;(?<-2>\d+,)*(\d+))(1)*,(?(4)$)(?<-4>1)*(,1*)?;(\d+,)*)\d+
$1
```
Match an integer in `L`, with index `$#4` equalling either `a` or `b` (using a .NET balancing group), then match the other index in `$#2`, and match the integer at that index as the replacement for this integer (also using a .NET balancing group).
```
.*;
```
Delete `a` and `b`.
[Answer]
# [Red](http://www.red-lang.org), 33 bytes
```
func[l a b][swap at l a at l b l]
```
[Try it online!](https://tio.run/##PY7BCsIwDIbve4r/5klYq6vVwx7Ca8ih21oU6jbmxMevWauGQPj@L4QsfkhXP4C4CpcUXmNPEQ4d0/PtZrgVG@bRIXIK0@Jdf8N3C1RBihQ0DjiigcEJFmeomoVt0eIslLCq/80SmKKb7OTCljW/zGykC2mxujDTvNzHFfSY4pC/67Dbt8gYSsCcPg "Red – Try It Online")
1-indexed
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~24~~ 21 bytes
1-based indices, input is a list and a tuple of indices to reverse
```
Reverse~SubsetMap~##&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7Pyi1LLWoOLUuuDSpOLXEN7GgTllZ7X9AUWZeiUNadLWhjpGOsY6JjqmOmY65joWOpY6hQa1OtbGOeW3sfwA "Wolfram Language (Mathematica) – Try It Online")
-3 bytes thanks to att.
[Answer]
# [Core Maude](http://maude.cs.illinois.edu/w/index.php/The_Maude_System), 158 bytes
```
mod S is pr ARRAY{Nat,Nat0}*(sort Array{Nat,Nat0}to A). var I J X Y : Nat . op
s : A Nat Nat -> A . eq s(A:A,I,J)= insert(I,A:A[J],insert(J,A:A[I],A:A)). endm
```
### Example Session
```
             \||||||||||||||||||/
           --- Welcome to Maude ---
             /||||||||||||||||||\
         Maude 3.1 built: Oct 12 2020 20:12:31
         Copyright 1997-2020 SRI International
               Sat Oct 16 22:01:13 2021
Maude> mod S is pr ARRAY{Nat,Nat0}*(sort Array{Nat,Nat0}to A). var I J X Y : Nat . op
> s : A Nat Nat -> A . eq s(A:A,I,J)= insert(I,A:A[J],insert(J,A:A[I],A:A)). endm
Maude> red s(0 |-> 1 ; 1 |-> 2 ; 2 |-> 3 ; 3 |-> 4 ; 4 |-> 5 ; 5 |-> 6 ; 6 |-> 7 ;
>       7 |-> 8 ; 8 |-> 9 ; 9 |-> 10, 3, 7) .
result A: 0 |-> 1 ; 1 |-> 2 ; 2 |-> 3 ; 3 |-> 8 ; 4 |-> 5 ; 5 |-> 6 ; 6 |-> 7 ;
    7 |-> 4 ; 8 |-> 9 ; 9 |-> 10
Maude> red s(0 |-> 3 ; 1 |-> 8 ; 2 |-> 1 ; 3 |-> 4 ; 4 |-> 10 ; 5 |-> 10 ; 6 |-> 10 ;
>       7 |-> 10, 0, 5) .
result A: 0 |-> 10 ; 1 |-> 8 ; 2 |-> 1 ; 3 |-> 4 ; 4 |-> 10 ; 5 |-> 3 ; 6 |->
    10 ; 7 |-> 10
Maude> red s(0 |-> 5 ; 1 |-> 1 ; 2 |-> 4 ; 3 |-> 2 ; 4 |-> 3, 0, 4) .
result A: 0 |-> 3 ; 1 |-> 1 ; 2 |-> 4 ; 3 |-> 2 ; 4 |-> 5
Maude> red s(0 |-> 5 ; 1 |-> 6, 0, 1) .
result A: 0 |-> 6 ; 1 |-> 5
Maude> red s(0 |-> 2 ; 1 |-> 2 ; 2 |-> 2, 0, 1) .
result A: 0 |-> 2 ; 1 |-> 2 ; 2 |-> 2
```
### Ungolfed
```
mod S is
    pr ARRAY{Nat,Nat0} * (sort Array{Nat,Nat0} to A).
    var I J X Y : Nat .
    op s : A Nat Nat -> A .
    eq s(A:A, I, J) = insert(I, A:A[J], insert(J, A:A[I], A:A)) .
endm
```
The answer is obtained by reducing the function `s` with the list, given as a Maude array (e.g., `0 |-> 1 ; 1 |-> 2` for `[1, 2]`), and the two indices, zero-indexed.
Maude does have lists (e.g., `0 1` for the same list `[1, 2]`), but this is one case where it's actually shorter to use arrays (which are generally very verbose) because we don't need to use an array literal syntax in the code, and because we need indexing. The FAQ says [it's allowed to accept input as either an array or a list](https://codegolf.meta.stackexchange.com/a/16670/45870).
[Answer]
# Javascript 38 bytes
```
(l,a,b)=>(l[a]=[l[b],l[b]=l[a]][0])&&l
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 4 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
è¹Rǝ
```
Since no one posted an 05AB1E answer yet and it's been a couple of days, I'm gonna post my prepared 4-byter.
First input is a pair of indices \$[a,b]\$, second input is the list \$L\$.
[Try it online](https://tio.run/##yy9OTMpM/f//8IpDO4OOz/3/P9pYxzyWK9pQx0jHWMdEx1THTMdcx0LHUsfQIBYA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfWWCS9Ghlf8Przi0Luj43P86/6Ojo411zGN1og11jHSMdUx0THXMdMx1LHQsdQwNYmN1FKKjDXRMgfLGQDFDoLyhARzBpE2A0qZgSaARMEFDsKAZMtcIKG8UGxsLAA).
**Explanation:**
```
è    # Index the first (implicit) input into the second (implicit) input-list
 ¹   # Push the first input-indices again
  R  # Reverse them
   ǝ # Insert the values at those reversed indices into the (implicit) second input-list
     # (after which the result is output implicitly)
```
]