I\'m trying to do this from scratch, without the use of a library outside the standard lib. Heres my code:
permutations :: [a] -> [[a]] permutations (x:xs
I think that this is shorter and more elegant variant for what others are suggesting:
permutate :: (Eq a) => [a] -> [[a]] permutate [] = [[]] permutate l = [a:x | a <- l, x <- (permutate $ filter (\x -> x /= a) l)]