private Func <double, double> ParseFunction(string str) { var tree = NumExprParser.ExpToTree(str); var expr = NumExprToLinqExprTranslator.TranslateExprTree(tree); return(expr.Compile()); }
private void PerformIntegrationForCustomFunction() { string functionString = null; if ( Dialogs.TryRequestValue("Input function : ", s => true, s => { var tree = NumExprParser.ExpToTree(s); var expr = NumExprToLinqExprTranslator.TranslateExprTree(tree); functionString = tree.Apply(new NumExprStringCollector()); return(expr.Compile()); }, out var f)) { this.PerformIntegrationForFunction(x => f(x)); } else { Dialogs.PrintCancellation(); } }