6 lines
218 B
Haskell
6 lines
218 B
Haskell
|
|
permutations :: [a] -> [[a]]
|
||
|
|
permutations [] = [[]]
|
||
|
|
permutations xs = [ y:zs | (y,ys) <- select xs, zs <- permutations ys]
|
||
|
|
where select [] = []
|
||
|
|
select (x:xs) = (x,xs) : [ (y,x:ys) | (y,ys) <- select xs ]
|