Commits

Robert Smith committed 4ca0a1a

Add PERM-TO-LIST.

  • Participants
  • Parent commits d74965f

Comments (0)

Files changed (3)

    [Condition of type SIMPLE-ERROR]
 
 One can also create permutations with LIST-TO-PERM, which converts a
-list to a permutation.
+list to a permutation. The companion function PERM-TO-LIST does the
+opposite operation, but it's not recommended to use list
+representations of permutations.
 
 Lastly, there is an experimental reader macro for permutations, which
 are created at read time. To enable the syntax, use

File package.lisp

    #:perm                               ; Type, Structure
    #:enable-perm-reader
    #:list-to-perm
+   #:perm-to-list
    #:make-perm
    #:perm-identity
    #:perm-identity-p

File permutation.lisp

   (assert-valid-permutation-elements list)
   (%make-perm :spec (coerce (cons 0 (copy-list list)) 'vector)))
 
+(defun perm-to-list (perm)
+  "Convert a permutation PERM to a list representation."
+  (coerce (subseq (perm.spec perm) 1) 'list))
+
 (defun make-perm (&rest elements)
   "Construct a permutation from the numbers ELEMENTS."
   (list-to-perm elements))