Skip to content

Superfluous comparison? #2

@genos

Description

@genos

Hi! Thanks very much for this excellent code and accompanying blog post.

One thing I stumbled across in pouring over this to implement my own: I think there's an extraneous comparison in permutation-to-transpositions. In lines 79–83, we've got

(loop :while (< src dest) :do 
  (setf src (elt permutation src)))
  (cond
    ((< src dest) (push (cons src dest) swaps))       ;; <- this one here
    ((> src dest) (push (cons dest src) swaps)))))))

Since we loop as long as src is less than dest, will we ever need the first branch of this cond? Can we replace it with just (when (> src dest) …)?

Thanks again!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions