permutations -is:module

The permutations function returns the list of all permutations of the argument. Note that the order of permutations is not lexicographic. It satisfies the following property:
map (take n) (take (product [1..n]) (permutations ([1..n] ++ undefined))) == permutations [1..n]

Laziness

The permutations function is maximally lazy: for each n, the value of permutations xs starts with those permutations that permute take n xs and keep drop n xs.

Examples

>>> permutations "abc"
["abc","bac","cba","bca","cab","acb"]
>>> permutations [1, 2]
[[1,2],[2,1]]
>>> permutations []
[[]]
This function is productive on infinite inputs:
>>> take 6 $ map (take 3) $ permutations ['a'..]
["abc","bac","cba","bca","cab","acb"]
The permutations function returns the list of all permutations of the argument.
The permutations function returns the list of all permutations of the argument. Since: 4.20.0.0
The permutations function returns the list of all permutations of the argument.
>>> permutations "abc"
["abc","bac","cba","bca","cab","acb"]
permutations returns a list of all permutations of the argument.
> permutations "abc"
["abc","bac","cba","bca","cab","acb"]
The permutations function returns the list of all permutations of the argument.
>>> permutations "abc"
["abc","bac","cba","bca","cab","acb"]
The permutations function is maximally lazy: for each n, the value of permutations xs starts with those permutations that permute take n xs and keep drop n xs. This function is productive on infinite inputs:
>>> take 6 $ map (take 3) $ permutations ['a'..]
["abc","bac","cba","bca","cab","acb"]
Note that the order of permutations is not lexicographic. It satisfies the following property:
map (take n) (take (product [1..n]) (permutations ([1..n] ++ undefined))) == permutations [1..n]
Generate an infinite list of all finite (such that only finite number of elements change their positions) permutations of the argument.
>>> take 6 (fmap (take 3) (permutations (0...)))
[[0,1,2],[1,0,2],[2,1,0],[1,2,0],[2,0,1],[0,2,1]]
Not on Stackage, so not searched. Permutations of finite sets
O(n!). Returns the list of all permutations of the argument.
>>> permutations mempty
Slist {sList = [Slist {sList = [], sSize = Size 0}], sSize = Size 1}

>>> permutations $ slist "abc"
Slist {sList = [Slist {sList = "abc", sSize = Size 3},Slist {sList = "bac", sSize = Size 3},Slist {sList = "cba", sSize = Size 3},Slist {sList = "bca", sSize = Size 3},Slist {sList = "cab", sSize = Size 3},Slist {sList = "acb", sSize = Size 3}], sSize = Size 6}
permutations1 operates like permutations, but uses the knowledge that its input is non-empty to produce output where every element is non-empty.
permutations1 = fmap fromList . permutations . toList
permutations1 operates like permutations, but uses the knowledge that its input is non-empty to produce output where every element is non-empty.
permutations1 = fmap fromList . permutations . toList
Since: 4.20.0.0
Takes a list and returns a sorted list using Permutationsort algorithm

Examples

>>> permutationsort ([16, 23, 4, 8, 15, 42] :: [Int])
[4,8,15,16,23,42]
>>> permutationsort ([(1, 16), (5, 23), (2, 4) ,(3, 8), (0, 15) , (4, 42)] :: [(Int, Int)])
[(0,15),(1,16),(2,4),(3,8),(4,42),(5,23)]
Not on Stackage, so not searched. Permutations and universal set related functions for the phonetic-languages series
Not on Stackage, so not searched. Commonly used versions of the phonetic-languages-common package
Execute a set of actions (e.g. parsers) in each possible order Sequence a set of Alternative actions in each possible order, based on "Parsing Permutation Phrases", by Arthur Baars, Andres Loeh and S. Doaitse Swierstra, Haskell Workshop 2001. This is particularly useful for constructing a parser for permutations of elements. This version has a slightly different interface from the paper.