- changed status to resolved
CYCLES-TO-ONE-LINE can produce invalid permutations
Issue #4
resolved
[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)
-
reporter - Log in to comment
Make CYCLES-TO-ONE-LINE more robust to bad input. Fixes Issue
#4→ <<cset 555764bc1b11>>