mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
12 lines
303 B
Text
12 lines
303 B
Text
interface Utils exposes [ swap ] imports []
|
|
|
|
swap : Int, Int, List a -> List a
|
|
swap = \i, j, list ->
|
|
when Pair (List.get list i) (List.get list j) is
|
|
Pair (Ok atI) (Ok atJ) ->
|
|
list
|
|
|> List.set i atJ
|
|
|> List.set j atI
|
|
|
|
_ ->
|
|
[]
|