Skip to content

Permutations

Generates all permutations of a list.

$ wo 'Permutations[{a, b, c}]'
{{a, b, c}, {a, c, b}, {b, a, c}, {b, c, a}, {c, a, b}, {c, b, a}}
$ wo 'Permutations[{1, 2, 3}, {2}]'
{{1, 2}, {1, 3}, {2, 1}, {2, 3}, {3, 1}, {3, 2}}
$ wo 'Permutations[{1, 2}, {1}]'
{{1}, {2}}
$ wo 'Permutations[{a}]'
{{a}}
$ wo 'Permutations[{}]'
{{}}
$ wo 'Length[Permutations[Range[4]]]'
24