def swap_at
import bendlib-kernel-list@1.0.0.0/list.bend as Listimport Base
17# Swap positions i and i+1.
18def swap_at(-A: Data, +i: Nat, xs: List<&2, A>) -> List<&2, A>:
19 match i:
20 case 0n:
21 swap_head(A, xs)
22 case 1n+p:
23 match xs:
24 case Nil{}:
25 Nil{}
26 case +x <> t:
27 x <> swap_at(A, p, t)