public List <Object> LoadExpression(string formula, Dictionary <string, IFunctionConponent> funcDic)
 {
     try
     {
         return(ComputerCore <GeneralNode> .LoadExpression(formula));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #2
0
        public double Compute(string expression)
        {
            string[] args = this.LoadArgs(expression);
            if (Validation(args))
            {
                int    stackdeep = 0;
                double temp      = ComputerCore <GeneralNode> .Compute(ComputerCore <GeneralNode> .Scan(ComputerCore <GeneralNode> .LoadExpression(args[0]), ref stackdeep));

                int retInt = 0;
                if (Int32.TryParse(temp.ToString(), out retInt))
                {
                    if (retInt < 0)
                    {
                        throw new Exception("Jiechen函数不能为负数!");
                    }
                    else
                    {
                        Factorial  f      = new Factorial(retInt);
                        List <int> result = f.Calculate();
                        String     ret    = f.ToString();
                        return(Double.Parse(ret));
                    }
                }
                throw new Exception("JieChen函数只能作用与Int! " + temp.ToString());
            }
            throw new Exception("Validation Failed!");
        }
Exemple #3
0
        public double Compute(string expression)
        {
            string[] args = this.LoadArgs(expression);
            if (Validation(args))
            {
                int    stackdeep = 0;
                double temp      = ComputerCore <GeneralNode> .Compute(ComputerCore <GeneralNode> .Scan(ComputerCore <GeneralNode> .LoadExpression(args[0]), ref stackdeep));

                int retInt = 0;
                if (Int32.TryParse(temp.ToString(), out retInt))
                {
                    return(~retInt);
                }
                throw new Exception("QiuFan函数只能作用与Int! " + temp.ToString());
            }
            throw new Exception("Validation Failed!");
        }
Exemple #4
0
        public double Compute(string expression)
        {
            string[] args = LoadArgs(expression);
            double[] rets = new double[args.Length];
            if (Validation(args))
            {
                int stackdeep = 0;
                for (int i = 0; i < rets.Length; i++)
                {
                    rets[i] = ComputerCore <GeneralNode> .Compute(ComputerCore <GeneralNode> .Scan(ComputerCore <GeneralNode> .LoadExpression(args[i]), ref stackdeep));
                }

                return(rets[0] + rets[1] + rets[2]);
            }
            throw new Exception("Validation Failed!");
        }
Exemple #5
0
        public double Compute(string expression)
        {
            string[] args = LoadArgs(expression);
            double   ret  = default(double);

            if (Validation(args))
            {
                for (int i = 0; i < args.Length; i++)
                {
                    int stackdeep = 0;
                    ret += ComputerCore <GeneralNode> .Compute(ComputerCore <GeneralNode> .Scan(ComputerCore <GeneralNode> .LoadExpression(args[i]), ref stackdeep));
                }
                return(ret);
            }
            throw new Exception("Validation Failed!");
        }
Exemple #6
0
 public double Compute(string expression)
 {
     string[] args = LoadArgs(expression);
     if (Validation(args))
     {
         int stackdeep = 0;
         return(Math.Log10(ComputerCore <GeneralNode> .Compute(ComputerCore <GeneralNode> .Scan(ComputerCore <GeneralNode> .LoadExpression(args[0]), ref stackdeep))));
     }
     throw new Exception("Validation Failed!");
 }