Greetings All,
I have a question about permutations (the function) which I was hoping to code hack to determine the path that the permutations would take. Ideally, instead of using permutation to generate:
((1 2 3)
(1 3 2)
(2 1 3)
(2 3 1)
(3 1 2)
(3 2 1)).
I would like the following:
((123)
(213)
(231)
(321)
(312)
(132)
(123))
The following steps would be useful to be able to control: let a = swap adjacent pairs, b = swap individual (specified) pairs, c = an integer to remain unchanged in the next permutation (eg. (132) (123)) and then be able to recall the original sublist (in the above case (123)) at the end. My lisp skills are rudimentary to put it kindly, but I’m sure this kind of recursive permutation is perfect for lisp. Would anyone be able to help? To be able to control adjacent pair swapping would help if nothing else. With the above a,b,c & d I would also be able to generate the following (for instance):
123
132
312
321
231
213
123
and of course scale up to any number of integers in a list.
Thanks in advance,
Krhes