Skip to content

Instantly share code, notes, and snippets.

@dmjio
Created July 9, 2020 04:50
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 dmjio/8ae058d9f1ea807f4c8737fd87b9b028 to your computer and use it in GitHub Desktop.
Save dmjio/8ae058d9f1ea807f4c8737fd87b9b028 to your computer and use it in GitHub Desktop.
perms [] = []
perms [x] = [pure x]
perms k@(z:zs) = do
(ls,rs) <-
splitAt
<$> [ 0 .. length zs ]
<*> perms zs
pure (ls ++ [z] ++ rs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment