Ejemplo n.º 1
0
		private static bool ReduceMultipliedAlphabeticFactors(ComponentListFactor leftFactor, ComponentListFactor rightFactor, out Expression expression)
		{
			// If any alphabetic factors are identical, convert to exponent
			if (leftFactor.Factor is AlphabeticFactor && rightFactor.Factor is AlphabeticFactor)
			{
				var leftAlpha = (AlphabeticFactor) leftFactor.Factor;
				var rightAlpha = (AlphabeticFactor) rightFactor.Factor;

				if (leftAlpha.Value.Equals(rightAlpha.Value))
				{
					var shouldPower = leftFactor.IsInNumerator && rightFactor.IsInNumerator;
					if (shouldPower)
					{
						expression = new SingleComponentExpression(new FunctionComponent("^", new List<Expression> { Expressionizer.ToExpression(leftAlpha), NumberToExpression(new Integer(2)) }));
						return true;
					}

					expression = NumberToExpression(new Integer(1));
					return true;
				}
			}

			expression = null;
			return false;
		}
Ejemplo n.º 2
0
		public void ZeroExpressionTest()
		{
			var exp = new SingleComponentExpression(new SingleFactorComponent(new NumericFactor(new Integer(0))));
			Assert.AreEqual("0", exp.ToString());
		}