Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add overload for Substitute(MathObject a, int b)

  • Loading branch information...
commit 786e400f8d3ab4c4a479aea95eebdafb360b7e67 1 parent b195a5d
dharmatech authored February 03, 2013
4  Symbolism/Program.cs
@@ -142,8 +142,8 @@ public MathObject Substitute(MathObject a, MathObject b)
142 142
             return this;
143 143
         }
144 144
 
145  
-        //public MathObject Substitute(MathObject a, int b)
146  
-        //{ return Substitute(a, new Integer(b)); }
  145
+        public MathObject Substitute(MathObject a, int b)
  146
+        { return Substitute(a, new Integer(b)); }
147 147
 
148 148
         public int Precedence()
149 149
         {
22  Tests/Program.cs
@@ -90,8 +90,8 @@ static void Main(string[] args)
90 90
                 AssertIsTrue(x - y == x + -1 * y);
91 91
 
92 92
 
93  
-                AssertIsTrue(Int(10).Substitute(Int(10), Int(20)) == 20);
94  
-                AssertIsTrue(Int(10).Substitute(Int(15), Int(20)) == 10);
  93
+                AssertIsTrue(Int(10).Substitute(Int(10), 20) == 20);
  94
+                AssertIsTrue(Int(10).Substitute(Int(15), 20) == 10);
95 95
 
96 96
                 AssertIsTrue(new DoubleFloat(1.0).Substitute(new DoubleFloat(1.0), new DoubleFloat(2.0)) == 2.0);
97 97
                 AssertIsTrue(new DoubleFloat(1.0).Substitute(new DoubleFloat(1.5), new DoubleFloat(2.0)) == 1.0);
@@ -102,10 +102,10 @@ static void Main(string[] args)
102 102
                 AssertIsTrue(x.Substitute(x, y) == y);
103 103
                 AssertIsTrue(x.Substitute(y, y) == x);
104 104
 
105  
-                AssertIsTrue((x ^ y).Substitute(x, Int(10)) == (10 ^ y));
106  
-                AssertIsTrue((x ^ y).Substitute(y, Int(10)) == (x ^ 10));
  105
+                AssertIsTrue((x ^ y).Substitute(x, 10) == (10 ^ y));
  106
+                AssertIsTrue((x ^ y).Substitute(y, 10) == (x ^ 10));
107 107
 
108  
-                AssertIsTrue((x ^ y).Substitute(x ^ y, Int(10)) == 10);
  108
+                AssertIsTrue((x ^ y).Substitute(x ^ y, 10) == 10);
109 109
 
110 110
                 AssertIsTrue((x * y * z).Substitute(x, y) == ((y ^ 2) * z));
111 111
                 AssertIsTrue((x * y * z).Substitute(x * y * z, x) == x);
@@ -115,9 +115,9 @@ static void Main(string[] args)
115 115
 
116 116
                 AssertIsTrue(
117 117
                     ((((x * y) ^ (Int(1) / 2)) * (z ^ 2)) ^ 2)
118  
-                        .Substitute(x, Int(10))
119  
-                        .Substitute(y, Int(20))
120  
-                        .Substitute(z, Int(3))
  118
+                        .Substitute(x, 10)
  119
+                        .Substitute(y, 20)
  120
+                        .Substitute(z, 3)
121 121
                         == 16200
122 122
                         );
123 123
 
@@ -129,7 +129,7 @@ static void Main(string[] args)
129 129
 
130 130
                 AssertIsTrue(sin(x + x) == sin(2 * x));
131 131
 
132  
-                AssertIsTrue(sin(x + x).Substitute(x, Int(1)) == sin(Int(2)));
  132
+                AssertIsTrue(sin(x + x).Substitute(x, 1) == sin(Int(2)));
133 133
 
134 134
                 AssertIsTrue(sin(x + x).Substitute(x, new DoubleFloat(1.0)) == 0.90929742682568171);
135 135
 
@@ -198,7 +198,7 @@ static void Main(string[] args)
198 198
                     .Substitute(thA, Trig.ToRadians(20))
199 199
                     .Substitute(g, new DoubleFloat(9.8))
200 200
                     .Substitute(Trig.Pi, new DoubleFloat(3.14159))
201  
-                    .Substitute(vA, new Integer(11))
  201
+                    .Substitute(vA, 11)
202 202
                     ==
203 203
                     7.9364536850196412);
204 204
 
@@ -209,7 +209,7 @@ static void Main(string[] args)
209 209
                     .Substitute(g, new DoubleFloat(9.8))
210 210
                     .Substitute(thA, Trig.ToRadians(20))
211 211
                     .Substitute(Trig.Pi, new DoubleFloat(3.14159))
212  
-                    .Substitute(vA, new Integer(11)) 
  212
+                    .Substitute(vA, 11) 
213 213
                     ==
214 214
                     0.72215756424454336);
215 215
             }

0 notes on commit 786e400

Please sign in to comment.
Something went wrong with that request. Please try again.