Roger Hui wrote:
> Once you assume that an operation is to be done
> in place, swapping items at the front or at
> the back are the same. There is free space
> at the back and none at the front, but neither
> matter if you are just swapping.
>
> As you'd indicated, in general the operation is:
> name=: p{name
> where p is a permutation and p=&#name .
Roger:
Maybe this is solving the problem in too much generality to be
efficient.
Postscript gets by with just two operations for this purpose: swap
(which interchanges the top two elements on the stack) and roll (which
does a cyclic shift of the top n elements). As you know, a
transposition and a cycle of length n will generate the permutation
group on n letters.
Best wishes,
John
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm