combinat::permute
--
permutations of a listcombinat::permute
(list) computes all the reorderings of
the given list list
.
combinat::permute
(n) computes all the reorderings of
the list [1,2,...,n].
combinat::permute(n)
combinat::permute(list)
combinat::permute(list,Duplicate)
n |
- | a nonnegative integer |
list |
- | a list |
Duplicate |
- | The result may contain identical lists if there are
duplicates in the given list list . |
A list of type DOM_LIST
containing every reordered
list as an element.
Duplicate
,
all lists in the result are distinct.There are exactly two ways of ordering two elements.
>> combinat::permute([a,b])
[[a, b], [b, a]]
An integer argument n is equivalent to the list of the first n integers.
>> combinat::permute(3)
[[2, 3, 1], [3, 2, 1], [1, 3, 2], [3, 1, 2], [1, 2, 3], [2, 1, 3]]
By default, one gets all distinct reorderings.
>> combinat::permute([a,a,b])
[[a, b, a], [b, a, a], [a, a, b]]
But if one wants to get a list with duplicated reordered entries, this is also possible.
>> combinat::permute([a,a,b],Duplicate)
[[a, b, a], [b, a, a], [a, b, a], [b, a, a], [a, a, b], [a, a, b]]
Sets are not allowed as an argument.
>> combinat::permute({3,4})
Error: argument must be a list or a non-negative integer! [com\ binat::permute]
combinat::permute
().