-
Notifications
You must be signed in to change notification settings - Fork 3
/
ccomplex.lisp
47 lines (38 loc) · 1.58 KB
/
ccomplex.lisp
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
(in-package #:ctype)
(defmethod ctypep ((object complex) (ct ccomplex))
(complex-ucptp object (ccomplex-ucpt ct)))
(defmethod ctypep ((object t) (ct ccomplex)) nil)
(defmethod subctypep ((ct1 ccomplex) (ct2 ccomplex))
(values (equal (ccomplex-ucpt ct1) (ccomplex-ucpt ct2)) t))
(defmethod ctype= ((ct1 ccomplex) (ct2 ccomplex))
(values (equal (ccomplex-ucpt ct1) (ccomplex-ucpt ct2)) t))
(defmethod disjointp ((ct1 ccomplex) (ct2 ccomplex))
(let ((ucpt1 (ccomplex-ucpt ct1)) (ucpt2 (ccomplex-ucpt ct2)))
(cond ((eq ucpt1 '*) (values t t))
((eq ucpt2 '*) (values t t))
(t (values (equal ucpt1 ucpt2) t)))))
(defmethod conjointp ((ct1 ccomplex) (ct2 ccomplex)) (values nil t))
(defmethod cofinitep ((ct ccomplex)) (values nil t))
(defmethod conjoin/2 ((ct1 ccomplex) (ct2 ccomplex))
(let ((ucpt1 (ccomplex-ucpt ct1)) (ucpt2 (ccomplex-ucpt ct2)))
(cond ((eq ucpt1 '*) ct2)
((eq ucpt2 '*) ct1)
((equal ucpt1 ucpt2) ct1)
(t (bot)))))
(defmethod disjoin/2 ((ct1 ccomplex) (ct2 ccomplex))
(let ((ucpt1 (ccomplex-ucpt ct1)) (ucpt2 (ccomplex-ucpt ct2)))
(cond ((eq ucpt1 '*) ct1)
((eq ucpt2 '*) ct2)
((equal ucpt1 ucpt2) ct1)
(t nil))))
(defmethod subtract ((ct1 ccomplex) (ct2 ccomplex))
(let ((ucpt1 (ccomplex-ucpt ct1)) (ucpt2 (ccomplex-ucpt ct2)))
(cond ((eq ucpt2 '*) (bot))
((eq ucpt1 '*) nil)
((equal ucpt1 ucpt2) (bot))
(t ct1))))
(defmethod unparse ((ct ccomplex))
(let ((ucpt (ccomplex-ucpt ct)))
(if (eq ucpt '*)
'complex
`(complex ,ucpt))))