aboutsummaryrefslogtreecommitdiff
path: root/src/boot/strap/utility.clisp
blob: e52d92ea777d66a1bbc0eda52eefe90f7cfec9ca (plain)
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
(PROCLAIM '(OPTIMIZE SPEED))
(IMPORT-MODULE "initial-env")

(IN-PACKAGE "BOOTTRAN")

(PROVIDE "utility")

(EXPORT '(|objectMember?| |symbolMember?| |stringMember?| |charMember?|
             |scalarMember?| |listMember?|))

(DEFUN |objectMember?| (|x| |l|)
  (COND
    ((CONSP |l|)
     (OR (EQ |x| (CAR |l|)) (|objectMember?| |x| (CDR |l|))))
    (T (EQ |x| |l|))))

(DEFUN |genericMember?| (|x| |l| |p|)
  (COND
    ((NULL |l|) NIL)
    ((CONSP |l|)
     (OR (APPLY |p| |x| (CAR |l|) NIL)
         (|genericMember?| |x| (CDR |l|) |p|)))
    (T (APPLY |p| |x| |l| NIL))))

(DEFUN |symbolMember?| (|x| |l|) (|genericMember?| |x| |l| #'EQ))

(DEFUN |stringMember?| (|s| |l|) (|genericMember?| |s| |l| #'STRING=))

(DEFUN |charMember?| (|c| |l|) (|genericMember?| |c| |l| #'CHAR=))

(DEFUN |scalarMember?| (|x| |l|) (|genericMember?| |x| |l| #'EQL))

(DEFUN |listMember?| (|x| |l|) (|genericMember?| |x| |l| #'EQUAL))