Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
swap i j xs = let a = slice' 0 (i-1)
b = slice' (i+1) (j-1)
c = slice' (j+1) (length xs - 1)
in a ++ (xs!!j):b ++ (xs!!i):c
slice' i j = slice i j xs
slice i j = snd . splitAt i . fst . splitAt (j+1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment