Skip to content

Instantly share code, notes, and snippets.

@jutememo
Created April 25, 2011 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jutememo/940061 to your computer and use it in GitHub Desktop.
Save jutememo/940061 to your computer and use it in GitHub Desktop.
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