Beispiel #1
0
        static void Main(string[] args)
        {
            Tokenizer TL = new Tokenizer();

            //Console.WriteLine(MathFunc.Eval(MathFunc.Parsing(TL.Scan("pow(0.5,0.3)"))));
            Console.WriteLine(MathFunc.Eval(MathFunc.Parsing(TL.Scan("a*b+c")), new Dictionary <char, string> {
                { 'a', "5" },
                { 'b', "3" },
                { 'c', "-7" }
            }));
            //Console.WriteLine(Math.Pow(0.5,0.3));
        }
Beispiel #2
0
        public static string[] MultExec(IEnumerable <Token> stream, Dictionary <char, string>[] vari)
        {
            Queue Compiled = MathFunc.Parsing(stream);
            Queue backup   = new Queue(Compiled);

            string[] output = new string[vari.Length];
            try
            {
                for (int i = 0; i < vari.Length; i++)
                {
                    output[i] = (MathFunc.Eval(Compiled, vari[i]));
                    Compiled  = new Queue(backup);
                }
                return(output);
            }

            catch (Exception e)
            {
                throw new Exception("Error occured during processing the equation");
            }
        }