\
infix, some nicer notation for set operations here
This is only for one level precedence so use parathesis
when you use them and logical operaors can be chained, e.g.
(if (A ∋ x < a ≤ 1) f1 f2)
and ∧
or ∨
intersection ∩
union ∪
set-minus – (Tex minus)
set-plus ++ (Tex oplus was ugly in my emacs)
Logical operators are
∈ ⊂ ⊃ ∋ < > ≤ ≥ ≠
Operators supported are,
I'm using emacs cvs, M-X set-input-method TeX and you will get emacs symbols but the
backslash prefix will give you some pain.
\
(set *infixes* [])
(set *chains* [])
(set *infixes* [[∧] [∨] [∩] [∪] [–] [++]])
(set *chains* [[∈ ⊂ ⊃ ∋] [< > ≤ ≥ ≠]])
(define infix?
Op [] -> []
Op [L|LL] -> (if (element? Op L)
L
(infix? Op LL)))
(define process-infix
P [X] -> X
P [A Op | L] -> [(tr-op Op) A (process-infix P L)] where (element? Op P)
P Z -> (error "Wrong infix expression"))
\This is currently wrong in image\
(define process-chain
P [A Op B] -> [[(tr-op Op) A B]] where (element? Op P)
P [A Op B | L] -> [[(tr-op Op) A B] and |(process-chain P [B|L])] where (element? Op P)
P Z -> (error "Wrong infix chaining expression"))
(define infix
[define | L] -> [define|L]
[A Op ] -> [A Op]
[A Op | L] -> (let P (infix? Op (value *infixes*))
(if (= P NIL)
(let P (infix? Op (value *chains*))
(if (= P NIL)
[A Op | L]
(process-infix [and] (process-chain P [A Op | L]))))
(process-infix P [A Op | L])))
X -> X)
(define tr-op
∨ -> or
∧ -> and
∩ -> intersection
∪ -> union
– -> difference
++ -> setplus
X -> X)
(set Ω [])
(defmacro ¬
[X] -> [not X])
(sugar in infix 2)
(define setplus
X Y -> (let S (X ∩ Y)
((X S) ∪ (Y – S))))
(define ≤
X Y -> (not (X > Y)))
(define ≥
X Y -> (not (X < Y)))
(define ⊂
X Y -> (= (intersection X Y) X))
(define ⊃
X Y -> (= (intersection Y X) Y))
(define ∈
X Y -> (element? X Y))
(define ∋
X Y -> (element? Y X))