1. Robert Smith
  2. cl-permutation
  3. Issues
Issue #4 resolved

CYCLES-TO-ONE-LINE can produce invalid permutations

Robert Smith
repo owner created an issue

[from hg repo]

CYCLES-TO-ONE-LINE will produce invalid permutations if the cycles don't include fixed points. Example:

> (to-cycles (make-perm 1 3 2 5 4))
(#<CYCLE (2 3)> #<CYCLE (4 5)>)
> (cycles-to-one-line *)
#<PERM 2 3 4 5>

[comments]

[Robert Smith]

This problem has been mostly addressed, in that we now have:

PERM> (to-cycles (make-perm 1 3 2 5 4))
(#<CYCLE (4 5)> #<CYCLE (2 3)> #<CYCLE (1)>)
PERM> (cycles-to-one-line *)
#<PERM 4 5 2 3 1>

This will work for any permutation converted to a normalized cycle decomposition. However, cycles-to-one-line is still not mindful of "invalid" decompositions. For example,

PERM> (cycles-to-one-line (list (make-cycle 1) (make-cycle 5)))
#<PERM 1 5>

So it will be necessary to add some sanity checks, or have some useful default behavior.

Comments (1)

  1. Log in to comment