-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
54 lines (45 loc) · 1.17 KB
/
index.ts
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
export class Symbol {
value: string;
constructor(value: string) {
this.value = value;
}
}
type ConnectiveUnion = Connective | Symbol | string;
export class Connective {
arity: number;
args: (Connective | Symbol)[] = [];
constructor(...args: (ConnectiveUnion)[]) {
args.forEach((arg: ConnectiveUnion) => {
if (typeof arg === 'string') {
arg = new Symbol(arg);
}
this.args.push(arg);
});
this.arity = this.args.length;
}
}
export class Not extends Connective {
constructor(arg: ConnectiveUnion) {
super(arg);
}
}
export class And extends Connective {
constructor(arg1: ConnectiveUnion, arg2: ConnectiveUnion) {
super(arg1, arg2);
}
}
export class Or extends Connective {
constructor(arg1: ConnectiveUnion, arg2: ConnectiveUnion) {
super(arg1, arg2);
}
}
export class If extends Connective {
constructor(arg1: ConnectiveUnion, arg2: ConnectiveUnion) {
super(arg1, arg2);
}
}
export class Iff extends Connective {
constructor(arg1: ConnectiveUnion, arg2: ConnectiveUnion) {
super(arg1, arg2);
}
}