next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Macaulay2Doc :: permutations

permutations -- produce all permutations of a list

Synopsis

Description

i1 : permutations {a,b,c,d}

o1 = {{a, b, c, d}, {a, b, d, c}, {a, c, b, d}, {a, c, d, b}, {a, d, b, c},
     ------------------------------------------------------------------------
     {a, d, c, b}, {b, a, c, d}, {b, a, d, c}, {b, c, a, d}, {b, c, d, a},
     ------------------------------------------------------------------------
     {b, d, a, c}, {b, d, c, a}, {c, a, b, d}, {c, a, d, b}, {c, b, a, d},
     ------------------------------------------------------------------------
     {c, b, d, a}, {c, d, a, b}, {c, d, b, a}, {d, a, b, c}, {d, a, c, b},
     ------------------------------------------------------------------------
     {d, b, a, c}, {d, b, c, a}, {d, c, a, b}, {d, c, b, a}}

o1 : List
i2 : permutations 3

o2 = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 0, 1}, {2, 1, 0}}

o2 : List

Ways to use permutations :