コード例 #1
0
 public List <Object> LoadExpression(string formula, Dictionary <string, IFunctionConponent> funcDic)
 {
     try
     {
         return(ComputerCore <GeneralNode> .LoadExpression(formula));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #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!");
        }
コード例 #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!");
        }
コード例 #4
0
ファイル: FuncMyTest.cs プロジェクト: amwtke/myconputer
        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!");
        }
コード例 #5
0
ファイル: Sum.cs プロジェクト: amwtke/myconputer
        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!");
        }
コード例 #6
0
ファイル: log.cs プロジェクト: amwtke/myconputer
 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!");
 }