1 import Data.List (sort, inits, tails, nub)
7 let perms = permutations base
9 putStrLn $ unlines perms
11 permutations :: String -> [String]
14 permutations (x:[]) = [[x]]
15 permutations xs = concatMap (\(y, ys) -> map (y:) (permutations ys)) (selects xs)
17 selects :: String -> [(Char, String)]
19 selects xs = nub [(head t, h ++ (tail t))
20 | (h, t) <- zip (inits xs) (tails xs)