Robert Smith committed 7490a95


Comments (0)

Files changed (2)

+   #:permute
    #:rotate-cycle-clockwise             ; Possibly will be removed.
     (loop :for i :from 1 :to n
           :do (setf (aref perm*-spec (perm-eval perm i)) i)
           :finally (return (%make-perm :spec perm*-spec)))))
+(defun permute (perm a)
+  "Permute A according to PERM."
+  (assert (<= (perm-size perm)
+              (length a))
+          (perm a)
+          "Only able to permute arrays whose size is greater or equal to PERM.")
+  (let* ((len (length a))
+         (result (make-array len)))
+    (loop :for i :below len
+          :do (setf (aref result i)
+                    (aref a (1- (perm-eval* perm (1+ i)))))
+          :finally (return result))))
 ; HI!!!
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CYCLES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (defun orbit-of (n perm)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.