Permutations by swapping: Difference between revisions
Content added Content deleted
Line 473: | Line 473: | ||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
<lang haskell> |
<lang haskell> |
||
⚫ | |||
⚫ | |||
s_perm :: [a] -> [[a]] |
|||
s_perm = foldl aux [[]] |
|||
⚫ | |||
⚫ | |||
s_permutations :: [a] -> [([a], Int)] |
s_permutations :: [a] -> [([a], Int)] |
||
s_permutations = flip zip (cycle [1, -1]) . |
s_permutations = flip zip (cycle [1, -1]) . (foldl aux [[]]) |
||
where aux items x = do |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
main :: IO () |
main :: IO () |