iconEuler Reference

Permutations

Function to compute permutations.

Load this file with "load perm".

pn := 10;
function pid (n)

  Identity permuation of n elements.
function pmult (p,q)

  Multiply two permutations.
function pm (p,q)

  Multiply two permutations.
  Infix Notation
  Example:
  >pprint ptranspose(2,3,10) pm ptranspose(3,4,10)
  (2 3 4)
function ptranspose (i,j,n=none)

  Transposition of i and j in n elements.
function pprint (p)

  Print a permutation as product of cycles.
function pcycle (q,n=none)

  Transform a cycle q into a permutation of n elements.
function pinverse (p)

  Inverse of the permutation p.
function pmultcycles 

  Multiply all cycles in the argument list (right to left).
function forAllPerm (f,n)

  Do the function f(p) for all permutations p of n elements.
function forAllChoices (f,n,m)

  Do the function f(p) for all choices p of m elements out of 1:n
function forAllTrips (f,n)

  Do the function f(p) for all trips p of n elements.
function forAllOrderedChoices (f,n,m)

  Do the function f(p) for all ordered tupels of m elements in 1 to n.

Documentation Homepage