@@ -10,8 +10,7 @@ static void InsertAtAtomIndexAndAdvance(this MathList self, int atomIndex, MathA
10
10
if ( atomIndex < 0 || atomIndex > self . Count )
11
11
throw new IndexOutOfRangeException ( $ "Index { atomIndex } is out of bounds for list of size { self . Atoms . Count } ") ;
12
12
// Test for placeholder to the right of index, e.g. \sqrt{‸■} -> \sqrt{2‸}
13
- if ( atomIndex < self . Count && self [ atomIndex ] is MathAtom placeholder &&
14
- placeholder ? . AtomType is Enumerations . MathAtomType . Placeholder ) {
13
+ if ( atomIndex < self . Count && self [ atomIndex ] is Atom . Placeholder placeholder ) {
15
14
if ( placeholder . Superscript is MathList super ) {
16
15
if ( atom . Superscript != null ) super . Append ( atom . Superscript ) ;
17
16
atom . Superscript = super ;
@@ -57,7 +56,7 @@ public static void InsertAndAdvance(this MathList self, ref MathListIndex index,
57
56
break ;
58
57
case MathListSubIndexType . Degree :
59
58
case MathListSubIndexType . Radicand :
60
- if ( ! ( self . Atoms [ index . AtomIndex ] is Atom . Radical radical && radical . AtomType == Enumerations . MathAtomType . Radical ) )
59
+ if ( ! ( self . Atoms [ index . AtomIndex ] is Atom . Radical radical ) )
61
60
throw new SubIndexTypeMismatchException ( typeof ( Atom . Radical ) , index ) ;
62
61
if ( index . SubIndexType == MathListSubIndexType . Degree )
63
62
if ( radical . Degree is null ) throw new SubIndexTypeMismatchException ( index ) ;
@@ -66,8 +65,7 @@ public static void InsertAndAdvance(this MathList self, ref MathListIndex index,
66
65
break ;
67
66
case MathListSubIndexType . Numerator :
68
67
case MathListSubIndexType . Denominator :
69
- if ( ! ( self . Atoms [ index . AtomIndex ] is Atom . Fraction frac
70
- && frac . AtomType == Enumerations . MathAtomType . Fraction ) )
68
+ if ( ! ( self . Atoms [ index . AtomIndex ] is Atom . Fraction frac ) )
71
69
throw new SubIndexTypeMismatchException ( typeof ( Atom . Fraction ) , index ) ;
72
70
if ( index . SubIndexType == MathListSubIndexType . Numerator )
73
71
if ( frac . Numerator is null )
@@ -113,12 +111,12 @@ public static void RemoveAt(this MathList self, ref MathListIndex index) {
113
111
self . Atoms [ index . AtomIndex - 1 ] is MathAtom previous &&
114
112
previous . Subscript is null &&
115
113
previous . Superscript is null &&
116
- previous . AtomType switch {
117
- Enumerations . MathAtomType . BinaryOperator => false ,
118
- Enumerations . MathAtomType . UnaryOperator => false ,
119
- Enumerations . MathAtomType . Relation => false ,
120
- Enumerations . MathAtomType . Punctuation => false ,
121
- Enumerations . MathAtomType . Space => false ,
114
+ previous switch {
115
+ Atom . BinaryOperator _ => false ,
116
+ Atom . UnaryOperator _ => false ,
117
+ Atom . Relation _ => false ,
118
+ Atom . Punctuation _ => false ,
119
+ Atom . Space _ => false ,
122
120
_ => true
123
121
} ) {
124
122
previous . Superscript = currentAtom . Superscript ;
@@ -141,8 +139,7 @@ previous.Superscript is null &&
141
139
return ;
142
140
case MathListSubIndexType . Radicand :
143
141
case MathListSubIndexType . Degree :
144
- if ( ! ( self . Atoms [ index . AtomIndex ] is Atom . Radical radical
145
- && radical . AtomType == Enumerations . MathAtomType . Radical ) )
142
+ if ( ! ( self . Atoms [ index . AtomIndex ] is Atom . Radical radical ) )
146
143
throw new SubIndexTypeMismatchException ( typeof ( Atom . Radical ) , index ) ;
147
144
if ( index . SubIndexType == MathListSubIndexType . Degree )
148
145
if ( radical . Degree is null ) throw new SubIndexTypeMismatchException ( index ) ;
@@ -151,7 +148,7 @@ previous.Superscript is null &&
151
148
break ;
152
149
case MathListSubIndexType . Numerator :
153
150
case MathListSubIndexType . Denominator :
154
- if ( ! ( self . Atoms [ index . AtomIndex ] is Atom . Fraction frac && frac . AtomType == Enumerations . MathAtomType . Fraction ) )
151
+ if ( ! ( self . Atoms [ index . AtomIndex ] is Atom . Fraction frac ) )
155
152
throw new SubIndexTypeMismatchException ( typeof ( Atom . Fraction ) , index ) ;
156
153
if ( index . SubIndexType == MathListSubIndexType . Numerator )
157
154
if ( frac . Numerator is null ) throw new SubIndexTypeMismatchException ( index ) ;
@@ -196,7 +193,7 @@ public static void RemoveAtoms(this MathList self, MathListRange? nullableRange)
196
193
throw new NotSupportedException ( "Nuclear fission is not supported" ) ;
197
194
case MathListSubIndexType . Radicand :
198
195
case MathListSubIndexType . Degree :
199
- if ( ! ( self . Atoms [ start . AtomIndex ] is Atom . Radical radical && radical . AtomType == Enumerations . MathAtomType . Radical ) )
196
+ if ( ! ( self . Atoms [ start . AtomIndex ] is Atom . Radical radical ) )
200
197
throw new SubIndexTypeMismatchException ( typeof ( Atom . Radical ) , start ) ;
201
198
if ( start . SubIndexType == MathListSubIndexType . Degree )
202
199
if ( radical . Degree is null )
@@ -206,7 +203,7 @@ public static void RemoveAtoms(this MathList self, MathListRange? nullableRange)
206
203
break ;
207
204
case MathListSubIndexType . Numerator :
208
205
case MathListSubIndexType . Denominator :
209
- if ( ! ( self . Atoms [ start . AtomIndex ] is Atom . Fraction frac && frac . AtomType == Enumerations . MathAtomType . Fraction ) )
206
+ if ( ! ( self . Atoms [ start . AtomIndex ] is Atom . Fraction frac ) )
210
207
throw new SubIndexTypeMismatchException ( typeof ( Atom . Fraction ) , start ) ;
211
208
if ( start . SubIndexType == MathListSubIndexType . Numerator )
212
209
if ( frac . Numerator is null ) throw new SubIndexTypeMismatchException ( start ) ;
@@ -244,15 +241,15 @@ public static void RemoveAtoms(this MathList self, MathListRange? nullableRange)
244
241
case MathListSubIndexType . Radicand :
245
242
case MathListSubIndexType . Degree :
246
243
return
247
- atom is Atom . Radical radical && radical . AtomType == Enumerations . MathAtomType . Radical
244
+ atom is Atom . Radical radical
248
245
? index . SubIndexType == MathListSubIndexType . Degree
249
246
? radical . Degree ? . AtomAt ( index . SubIndex )
250
247
: radical . Radicand ? . AtomAt ( index . SubIndex )
251
248
: null ;
252
249
case MathListSubIndexType . Numerator :
253
250
case MathListSubIndexType . Denominator :
254
251
return
255
- atom is Atom . Fraction frac && frac . AtomType == Enumerations . MathAtomType . Fraction
252
+ atom is Atom . Fraction frac
256
253
? index . SubIndexType == MathListSubIndexType . Denominator
257
254
? frac . Denominator ? . AtomAt ( index . SubIndex )
258
255
: frac . Numerator ? . AtomAt ( index . SubIndex )
0 commit comments