-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLispInput2.txt
39 lines (30 loc) · 1009 Bytes
/
LispInput2.txt
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
(defun removeNILTop (L)
(cond ((null L) nil) ((and (not (null (car L))) (cons (car L) (removeNILTop (cdr L)))))
(T (append (car L) (removeNILTop (cdr L))))
)
)
(defun removeNILMost (L)
(cond ((null L) nil) ((not (atom (car L))) (cons (removeNILMost (car L)) (removeNILMost (cdr L)))) ((eql nil (car L)) (removeNILMost (cdr L)))
(T (cons (car L) (removeNILMost (cdr L))))
)
)
(defun reverseTop (L)
(cond ((null L) nil)
(T (append (reverseTop (cdr L)) (list (car L))))
)
)
(defun reverseAll (L)
(cond ((null L) nil) ((listp (car L)) (append (reverseAll (cdr L)) (list (reverseAll (car L)))))
(T (append (reverseAll (cdr L)) (list (car L))))
)
)
(defun palindrome (L)
(cond ((null L) nil)
(T (equal L (reverse L)))
)
)
(defun removeNILAll (L)
(cond ((null L) nil) ((null (car L)) (removeNILAll (cdr L))) ((atom (car L)) (cons (car L) (removeNILAll (cdr L))))
(T (append (removeNILAll (car L)) (removeNILAll (cdr L))))
)
)