permute - Maple Help

combinat

 permute
 construct the permutations of a list

 Calling Sequence permute(n) permute(n, r)

Parameters

 n - list/set of objects or an integer r - (optional) integer

Description

 • If n is a list or set, then permute returns a list of all the permutations of the elements of n, taken r at a time.  If n is a non-negative integer, it is interpreted in the same way as a list of the first n integers. If r is not specified, then it is taken to be equal to the number of elements in n.
 • The permutations are generated in order. Duplicates in n are respected.
 • The function numbperm will compute the number of possible permutations: numbperm(n, r) = nops(permute(n, r)).
 • The command with(combinat,permute) allows the use of the abbreviated form of this command.

Examples

 > $\mathrm{with}\left(\mathrm{combinat}\right):$
 > $\mathrm{permute}\left(3\right)$
 $\left[\left[{1}{,}{2}{,}{3}\right]{,}\left[{1}{,}{3}{,}{2}\right]{,}\left[{2}{,}{1}{,}{3}\right]{,}\left[{2}{,}{3}{,}{1}\right]{,}\left[{3}{,}{1}{,}{2}\right]{,}\left[{3}{,}{2}{,}{1}\right]\right]$ (1)
 > $\mathrm{permute}\left(3,2\right)$
 $\left[\left[{1}{,}{2}\right]{,}\left[{1}{,}{3}\right]{,}\left[{2}{,}{1}\right]{,}\left[{2}{,}{3}\right]{,}\left[{3}{,}{1}\right]{,}\left[{3}{,}{2}\right]\right]$ (2)
 > $\mathrm{permute}\left(\left[a,b\right]\right)$
 $\left[\left[{a}{,}{b}\right]{,}\left[{b}{,}{a}\right]\right]$ (3)
 > $\mathrm{permute}\left(\left\{a,b\right\}\right)$
 $\left[\left[{a}{,}{b}\right]{,}\left[{b}{,}{a}\right]\right]$ (4)
 > $\mathrm{permute}\left(\left[a,a,b\right],2\right)$
 $\left[\left[{a}{,}{a}\right]{,}\left[{a}{,}{b}\right]{,}\left[{b}{,}{a}\right]\right]$ (5)