Skip to content

Commit

Permalink
Simplify Product.Simplify. Add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmatech committed Jan 1, 2013
1 parent 8025aed commit 9b7de06
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Symbolism/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1048,13 +1048,7 @@ public MathObject Simplify()
{
if (elts.Count == 1) return elts[0];

Func<MathObject, bool> IsZero = obj =>
{
if (obj is Integer) return ((Integer)obj).val == 0;
return false;
};

if (elts.Any(IsZero)) return new Integer(0);
if (elts.Any(elt => elt == new Integer(0))) return new Integer(0);

var res = RecursiveSimplify(elts);

Expand Down Expand Up @@ -1375,6 +1369,10 @@ static void Main(string[] args)

AssertIsTrue(3.4 * x * 1.2 * y == 4.08 * x * y);

// Product.Simplify

AssertIsTrue(x * 0 == new Integer(0));

// Difference

AssertIsTrue(-x == -1 * x);
Expand Down

0 comments on commit 9b7de06

Please sign in to comment.