Skip to content

Instantly share code, notes, and snippets.

@fetfrum
Created December 28, 2019 05:47
Show Gist options
  • Save fetfrum/9ef802240fa2d8c2f4fe224f533cbe6f to your computer and use it in GitHub Desktop.
Save fetfrum/9ef802240fa2d8c2f4fe224f533cbe6f to your computer and use it in GitHub Desktop.
perms :: [a] -> [[a]]
perms [] = [[]]
perms xs = [ y:zs | (y,ys) <- select xs, zs <- perms ys]
where select [] = []
select (x:xs) = (x,xs) : [ (y,x:ys) | (y,ys) <- select xs ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment