Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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