summaryrefslogtreecommitdiffstats
path: root/tests/perm.tl
blob: d9df0b859e3d399e47996413614d5780e01413e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
(defun enc-perm (p)
  (let ((d (digits (logior 4096 p) 2)))
    (mapcar (do if (zerop @2) #\- @1) "sgtrwxrwxrwx" (rest d))))

(defun dec-perm (s)
  (let ((d (mapcar (do cond
                     ((eql @1 @2) 1)
                     ((eql #\- @2) 0)
                     (t (error `decode-perm: invalid input @s`)))
                   "sgtrwxrwxrwx" s)))
    (poly 2 d)))