-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paths.l
More file actions
119 lines (110 loc) · 2.4 KB
/
s.l
File metadata and controls
119 lines (110 loc) · 2.4 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
; my functions
(defun order (x y)
(cond
((numberp x)
(if (numberp y)
(if (= y x) (list x)
(if (< x y) (append (list x) (list y))
(append (list y) (list x))
)
)
(append (list x) (list y))
)
)
((numberp y)
(append (list x) (list y))
)
(t (append (list x) (list y) ))
)
)
(defun combine-recursive (x y)
(cond
((null x) nil)
((null y) nil)
((not (listp x)) nil)
((not (listp y)) nil)
((not (= (length x) (length y))) nil)
(t (cons (order (car x) (car y)) (combine-recursive (cdr x) (cdr y))))
)
)
(defun combine-mapcar (x y)
(cond
((null x) nil)
((null y) nil)
((not (listp x)) nil)
((not (listp y)) nil)
((not (= (length x) (length y))) nil)
(t (mapcar `order x y))
)
)
(defun combine-iterative (x y)
(cond
((null x) nil)
((null y) nil)
((not (listp x)) nil)
((not (listp y)) nil)
((not (= (length x) (length y))) nil)
(t (do ( (x1 x (cdr x1)) (y1 y (cdr y1)) (lst nil) )
((null x1) lst)
(setq lst (append lst (list (order (car x1) (car y1)))))
)
)
)
)
(defun remove-if-recursive (f x)
(cond
((null f) nil)
((null x) nil)
(t (append (if (funcall f (car x)) nil (list (car x)))
(remove-if-recursive f (cdr x))
)
)
)
)
(defun remove-if-mapcar (f x)
(cond
((null f) nil)
((null x) nil)
(t (apply #'append (mapcar #'(lambda (x1) (if (funcall f x1) nil (list x1))) x)))
)
)
(defun simplify (x)
(cond
((null x) nil)
((not (listp x)) x)
((listp (car x))
(append (if (null (simplify (car x))) nil (list (simplify (car x))))
(if (null (simplify (cdr x))) nil (simplify (cdr x)))
)
)
((eq (car x) `not)
(if (listp (cadr x))
(if (eq (car (cadr x)) `not)
(simplify (cadr (cadr x)))
(append (list (car x)) (list (simplify (cadr x))))
)
x ; return original list
)
) ; NOT
((eq (car x) `and)
(append (list (car x))
(rem (simplify (cdr x)) `and)
)
) ; AND
((eq (car x) `or)
(append (list (car x))
(rem (simplify (cdr x)) `or)
)
) ; OR
(t (append (list (car x)) (simplify (cdr x))))
)
)
(defun rem (x s)
(cond
((null x) nil)
((listp (car x))
(append (if (eq (car (car x)) s) (cdr (car x)) (list (car x))) (rem (cdr x) s))
)
(t (append (list (car x)) (rem (cdr x) s)))
)
)