Skip to content

Instantly share code, notes, and snippets.

@clojj
Last active November 15, 2018 10:18
Show Gist options
  • Save clojj/738dd4a43c8f89f3247eaceca21b11b8 to your computer and use it in GitHub Desktop.
Save clojj/738dd4a43c8f89f3247eaceca21b11b8 to your computer and use it in GitHub Desktop.
permutations :: (Eq a) => [a] -> [[a]]
permutations [] = [[]]
permutations l = [a:x | a <- l, x <- (permutate $ filter (\x -> x /= a) l)]
allUnique :: Eq a => [a] -> Bool
allUnique [] = True
allUnique ls = and [r | x <- ls, r <- [length (filter (\e -> e /= x) ls) == (length ls) - 1]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment