public double Compute(INode root) { try { return(ComputerCore <GeneralNode> .Compute(root)); } catch (Exception ex) { throw ex; } }
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!"); }
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!"); }
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!"); }
public double Compute(string expression) { int stackdeep = 0; string[] args = LoadArgs(expression); double ret = default(double); int begin = Convert.ToInt32(ComputerCore <GeneralNode> .Compute(args[0], ref stackdeep)); int end = Convert.ToInt32(ComputerCore <GeneralNode> .Compute(args[1], ref stackdeep)); //变量参数 string[] innerArgs6 = LoadArgs(args[5]); string ars6 = args[5]; string[] innerArg5 = LoadArgs(args[4]); string ars5 = args[4]; string[] innerArg4 = LoadArgs(args[3]); string ars4 = args[3]; string[] innerArg3 = LoadArgs(args[2]); string ars3 = args[2]; if (Validation(args)) { for (; begin <= end; begin++) { foreach (string s in innerArg5) { args[4] = args[4].ToLower().Replace(s, begin.ToString()); args[4] = ComputerCore <GeneralNode> .Compute(args[4], ref stackdeep).ToString(); } foreach (string s in innerArg4) { args[3] = args[3].ToLower().Replace(s, begin.ToString()); args[3] = ComputerCore <GeneralNode> .Compute(args[3], ref stackdeep).ToString(); } foreach (string s in innerArg3) { args[2] = args[2].ToLower().Replace(s, begin.ToString()); args[2] = ComputerCore <GeneralNode> .Compute(args[2], ref stackdeep).ToString(); } args[5] = args[5].ToLower().Replace(innerArgs6[0], args[2]); args[5] = args[5].ToLower().Replace(innerArgs6[1], args[3]); args[5] = args[5].ToLower().Replace(innerArgs6[2], args[4]); ret += ComputerCore <GeneralNode> .Compute(args[5], ref stackdeep); args[5] = ars6; args[2] = ars3; args[3] = ars4; args[4] = ars5; } return(ret); } throw new Exception("Validation Failed!"); }