COMB P,L / P=PERMUTATIONS,<n> lists all permutations of <n> given elements (default 1,2,3,...) in lexicographic order. Example: COMB PERM,CUR+1 / PERM=PERMUTATIONS,3 Permutations of 3 elements: N[PERM]=6 1 2 3 1 3 2 2 1 3 2 3 1 3 1 2 3 2 1 COMB P,L / P=PERMUTATIONS,<n>,<m> lists <m>-permutations of <n> given elements (default 1,2,3,...) in lexicographic order. Example: COMB PERM,CUR+1 / PERM=PERMUTATIONS,4,2 ELEMENTS=A,B,C,D 2-permutations of 4 elements: N[PERM]=12 A B A C A D B A B C B D C A C B C D D A D B D C ELEMENTS=<list_of_elements_with_repetitions> COMB P,L / P=PERMUTATIONS,<n>,<m> lists <m>-permutations of <n> in lexicographic order from a list given by ELEMENTS. Example: COMB PERM,CUR+1 / PERM=PERMUTATIONS,5,3 ELEMENTS=A,A,A,B,B 3-permutations of 5 elements (with repetitions): N[PERM]=7 A A A A A B A B A A B B B A A B A B B B A ................................................................................ Permutations with restricted positions: COMB PERM,CUR+1 / PERM=R_PERMUTATIONS,<n> RESTRICTIONS=<matrix_file> lists permutations of <n> elements with restricted positions given by non-zero elements in <n>*<n> <matrix_file>. Example: MATRIX A5 /// 1 0 0 0 1 / `1' cannot be in positions 1,5. 0 1 1 0 0 / `2' cannot be in positions 2,3. 0 0 1 1 1 / `3' cannot be in positions 3,4,5. 1 1 0 0 0 / `4' cannot be in positions 1,2. 1 0 1 0 1 / `5' cannot be in positions 1,3,5. MAT SAVE A5 COMB PERM,CUR+1 / PERM=R_PERMUTATIONS,5 RESTRICTIONS=A5 Permutations of 5 elements with restrictions A5: N[PERM]=5 2 3 1 5 4 3 1 4 5 2 3 5 1 2 4 3 5 1 4 2 3 5 4 1 2 R_PERMUTATIONS is much quicker than PERMUTATIONS in cases of many restricted positions and somewhat slower in simple cases. PERMUTATIONS generates all permutations and cancels non-allowed cases. R_PERMUTATIONS uses a recursive algorithm where restrictions are observed already when permutations are generated. Example: 'i' not allowed in positions i-1,i,i+1 (i=1,..,n n+1=1) MATRIX A /// 1 1 0 0 0 0 0 0 0 0 1 MAT SAVE A MAT C=DIAGVEC(A) / *C~DIAGVEC(A) S11*11 /MATSHOW C,12 COMB P,CUR+1 / P=R_PERMUTATIONS,11 RESTRICTIONS=C RESULTS=0 Permutations of 11 elements with restrictions C: N[P]=1445100 is about 6 times faster than COMB P,CUR+1 / P=PERMUTATIONS,11 RESTRICTIONS=C RESULTS=0 C = Other forms of COMB