-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPERMUCNT.LSP
48 lines (37 loc) · 1.01 KB
/
PERMUCNT.LSP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
(defun new-perm (seq1 seq2 &aux tmp)
(setq seq1 (mapcar #'nth seq2 (setq tmp (mcl seq1))))
(free-cons tmp)
seq1
)
(defun memberqnth (elem lista &aux i)
(setq i 1)
(while t
(if (null lista) (return ()))
(if (equal (car lista) elem) (return i))
(setq lista (cdr lista))
(setq i (add1 i))
)
)
(defun get1cycle (seq &aux origseq seqs cycle)
(setq origseq seq)
(while (not (setq cycle (memberqnth seq seqs)))
(print seq)
(setq seqs (cons seq seqs))
(setq seq (new-perm seq origseq))
)
(setq *seqs* seqs)
(terpri)
(print seq)
cycle
)
(defun get2cycle (seq &aux seqs cycle)
(while (not (setq cycle (memberqnth seq seqs)))
(print seq)
(setq seqs (cons seq seqs))
(setq seq (new-perm seq seq))
)
(setq *seqs* seqs)
(terpri)
(print seq)
cycle
)