Пример #1
0
        // this function deals with the brakkets.

        void BracketSolver()
        {
            List <string> theKeep  = new List <string> ();
            int           counter  = 0;
            bool          insert   = false;
            int           startPos = 0;

            while (counter < theBatch.Count)
            {
                if (!theBatch.Contains("("))
                {
                    break;
                }
                string x = theBatch [counter];
                if (x == ")")
                {
                    insert = false;
                    int range = theKeep.Count;
                    List <Expression> theNewExpressionList = new List <Expression> ();
                    foreach (Expression exp in theExpressionList)
                    {
                        Expression e = new Expression(exp);
                        theNewExpressionList.Add(e);
                    }
                    DMASSolver sol = new DMASSolver(theNewExpressionList, theKeep);
                    if (sol.isProcessed())
                    {
                        Expression newOne = new Expression(sol.getSolution());
                        newOne.setEntireTag(autoNamer());
                        theExpressionList.Add(newOne);
                        theBatch [startPos] = newOne.getTag();
                        theBatch.RemoveRange(startPos + 1, range + 1);
                    }
                    else
                    {
                        Processed = false;
                        break;
                    }
                    counter = 0;
                    continue;
                }
                if (insert)
                {
                    theKeep.Add(x);
                }
                if (x == "(")
                {
                    theKeep  = new List <string> ();
                    startPos = counter;
                    insert   = true;
                }

                counter++;
            }
        }
Пример #2
0
 void Observe()
 {
     if (theBatch.Contains("("))
     {
         BracketSolver();
     }
     if (Processed)
     {
         DMASSolver SOL = new DMASSolver(theExpressionList, theBatch);
         if (isProcessed())
         {
             solution = SOL.getSolution();
         }
         else
         {
             Processed = false;
         }
     }
 }
Пример #3
0
        // this function deals with the brakkets.

        void BracketSolver()
        {
            List <string> theKeep  = new List <string> ();
            int           counter  = 0;
            bool          insert   = false;
            int           startPos = 0;

            while (counter < theBatch.Count)
            {
                if (!theBatch.Contains("(") && !theBatch.Contains("-("))
                {
                    break;
                }
                string x = theBatch [counter];
                if (x == ")")
                {
                    insert = false;
                    int range = theKeep.Count;
                    List <Expression> theNewExpressionList = new List <Expression> ();
                    foreach (Expression exp in theExpressionList)
                    {
                        Expression e = new Expression(exp);
                        theNewExpressionList.Add(e);
                    }
                    DMASSolver sol = new DMASSolver(theNewExpressionList, theKeep);
                    if (sol.isProcessed())
                    {
                        Expression newOne = new Expression(sol.getSolution());
                        if (theBatch [startPos].Contains("-"))
                        {
                            if (newOne.getExpType() == 1)
                            {
                                Matrix theMat = new Matrix(newOne.getMatrix());
                                theMat = theMat * -1;
                                newOne = new Expression(theMat);
                            }
                            else if (newOne.getExpType() == 2)
                            {
                                Number theNum = new Number();
                                theNum.setNumber(newOne.getNumber().getNumber() * -1);
                                newOne = new Expression(theNum);
                            }
                        }
                        newOne.setEntireTag(autoNamer());
                        theExpressionList.Add(newOne);
                        theBatch [startPos] = newOne.getTag();
                        theBatch.RemoveRange(startPos + 1, range + 1);
                    }
                    else
                    {
                        Processed = false;
                        break;
                    }
                    counter = 0;
                    continue;
                }
                if (insert)
                {
                    theKeep.Add(x);
                }
                if (x.TrimStart("-".ToCharArray()) == "(")
                {
                    theKeep  = new List <string> ();
                    startPos = counter;
                    insert   = true;
                }

                counter++;
            }
        }