-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhairiest.lisp
58 lines (57 loc) · 2.13 KB
/
hairiest.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
48
49
50
51
52
53
54
55
56
57
58
(defun print-xapping (xapping stream depth)
(declare (ignore depth))
(format stream
;; Are you ready for this one?
"~:[{~;[~]~:{~S~:[->~S~;~*~]~:^ ~}~:[~; ~]~
~{~S->~^ ~}~:[~; ~]~[~*~;->~S~;->~*~]~:[}~;]~]"
;; Is that clear?
(xectorp xapping)
(do ((vp (xectorp xapping))
(sp (finite-part-is-xetp xapping))
(d (xapping-domain xapping) (cdr d))
(r (xapping-range xapping) (cdr r))
(z '() (cons (list (if vp (car r) (car d))
(or vp sp)
(car r))
z)))
((null d) (reverse z)))
(and (xapping-domain xapping)
(or (xapping-exceptions xapping)
(xapping-infinite xapping)))
(xapping-exceptions xapping)
(and (xapping-exceptions xapping)
(xapping-infinite xapping))
(ecase (xapping-infinite xapping)
((nil) 0)
(:constant 1)
(:universal 2))
(xapping-default xapping)
(xectorp xapping)))
(defun print-xapping (xapping stream depth)
(declare (ignore depth))
(~format (~ stream)
(~wrap (if (xectorp xapping)
(values "[" "]")
(values "{" "}"))
(mapc (let ((vp (xectorp xapping))
(sp (finite-part-is-xetp xapping)))
(lambda (domain range)
(~S (if vp range domain))
(when (or vp sp) "->" (~S range))
((~^ :when :last-sublist))
" "))
(xapping-domain xapping)
(xapping-range xapping))
(when (and (xapping-domain xapping)
(or (xapping-exceptions xapping)
(xapping-infinite xapping)))
" ")
(dolist (~ (xapping-exceptions xapping))
(~S ~) "->" ~^ " ")
(when (and (xapping-exceptions xapping)
(xapping-infinite xapping))
" ")
(ecase (xapping-infinite xapping)
((nil))
(:constant "->" (xapping-default xapping))
(:universal "->")))))