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!"); }
public static double ComputeUfun(string wholething, string realArgs) { string expression = Parse(wholething, realArgs); int stackdeep = 0; return(ComputerCore <GeneralNode> .Compute(expression, ref stackdeep)); }
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[] innerArgs = LoadArgs(args[2]); string ars2 = args[2]; if (Validation(args)) { for (; begin <= end; begin++) { foreach (string s in innerArgs) { args[2] = args[2].ToLower().Replace(s, begin.ToString()); } ret += ComputerCore <GeneralNode> .Compute(args[2], ref stackdeep); args[2] = ars2; } return(ret); } throw new Exception("Validation Failed!"); }
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!"); }
public double Compute(INode root) { try { return(ComputerCore <GeneralNode> .Compute(root)); } catch (Exception ex) { throw ex; } }
public INode Scan(List <object> charInput) { try { return(ComputerCore <GeneralNode> .Scan(charInput, ref stackDeep)); } catch (Exception ex) { throw ex; } }
public List <Object> LoadExpression(string formula, Dictionary <string, IFunctionConponent> funcDic) { try { return(ComputerCore <GeneralNode> .LoadExpression(formula)); } catch (Exception ex) { throw ex; } }
// Update is called once per frame void Update() { if (ComputerCore == null) { ComputerCore = new ComputerCore(Program); } ComputerCore.Input1 = Input1.Value; ComputerCore.Step(); Output1.Value = ComputerCore.Output1; }
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!"); }
void Start() { ComputerCore = new ComputerCore(Program); }
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!"); }
public void CleanUp() { ComputerCore <GeneralNode> .CleanUp(); stackDeep = 0; }