FUNCTION: GenPerm - generate an element of the symmetric group
 
CALLING SEQUENCE:
-   GenPerm(n, typeperm)
-   GenPerm(perm, typeperm)
-   SG[GenPerm](n, typeperm)
-   SG[GenPerm](perm, typeperm)
-  
     
PARAMETERS:
- n        =  any positive integer
- perm     =  any list denoting a permutation
- typeperm =  'first', 'previous', 'next', 'last'
 
   
SYNOPSIS:
-  The  GenPerm  function  generates  one  element of a symmetric group  in
  lexicographic order, according to the parameter typeperm.
 
 
-  GenPerm(n, 'first') returns the first permutation of S(n).
 
 
-  GenPerm(n, 'last') returns the last permutation of S(n).
 
 
-  GenPerm(perm, 'previous')  gives  the  previous permutation according to
  the lexicographic order. It returns the NULL value when perm is  already
  the first permutation.
 
 
-  GenPerm(perm, 'next')  gives   the   next permutation  according  to the
  lexicographic order. It returns the NULL value when perm is already  the
  last permutation.
 
 
-  Whenever there is a  conflict  between  the  function  name  GenPerm and
  another   name   used   in   the   same   session, use   the  long  form
  SG['GenPerm'].
 
 
EXAMPLES:
> with(SG):
> GenPerm([3, 1, 4, 2], 'next');
 
                                [3, 2, 1, 4]
> GenPerm([3, 2, 1, 4], 'previous');
 
                                [3, 1, 4, 2]
 
SEE ALSO: