RemoveWhiteSpace() public static method

public static RemoveWhiteSpace ( string formula ) : string
formula string
return string
Ejemplo n.º 1
0
        public static void TestWhiteSpaceRemoval()
        {
            string formula = "ab cd";

            AssertSameValue(SolverTools.RemoveWhiteSpace(formula), "abcd");
            formula = "'ab cd'";
            AssertSameValue(SolverTools.RemoveWhiteSpace(formula), "'ab cd'");
            formula = " 'ab cd' ";
            AssertSameValue(SolverTools.RemoveWhiteSpace(formula), "'ab cd'");
            formula = " 'ab\\' cd ' ";
            AssertSameValue(SolverTools.RemoveWhiteSpace(formula), "'ab\\' cd '");
        }
Ejemplo n.º 2
0
        public Expression SymbolicateExpression(string formula, string[] localVariables = null)
        {
            Expression newExpression = new Expression();

            if (localVariables != null)
            {
                foreach (var localVariableName in localVariables)
                {
                    if (localVariableName[0] == '$')
                    {
                        newExpression.SetVariable(localVariableName.Substring(1, localVariableName.Length - 1).Trim(), "");
                    }
                    else
                    {
                        newExpression.SetVariable(localVariableName.Trim(), 0.0);
                    }
                }
            }

            formula = SolverTools.RemoveWhiteSpace(formula);

            // Check validity
            try
            {
                ValidityChecker.CheckValidity(formula);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }

            Symbol s = Symbolicate(formula, 0, formula.Length, newExpression);

            newExpression.root = s;
            return(newExpression);
        }