Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
swap 0 j xs'@(x:xs) = xs' !! j : take (j-1) xs
++ x : drop j xs
swap i j (x:xs) = x : swap (i-1) (j-1) xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment