Skip to content

Instantly share code, notes, and snippets.

@jutememo
Created April 25, 2011 03:42
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/940129 to your computer and use it in GitHub Desktop.
Save jutememo/940129 to your computer and use it in GitHub Desktop.
swap i j xs = swap' withIdx
where
withIdx = zip [0..] xs
swap' = map f
where
f (idx, x) | idx == i = xs !! j
| idx == j = xs !! i
| otherwise = x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment