permute n cmd
0 1 2
0 2 1
2 0 1
2 1 0
1 2 0
1 0 2
The cmd argument is a Tcl command that is invoked for every permutation that is generated. This command must accept a single argument. The argument will be a Tcl list consisting of the permuted numbers. To print the permutations to the screen, one could use the Tcl command puts:
permute 3 puts
Or the command could be defined by the user and do something like set the key for a columnar cipher to the permuted string.