public void EditFunction(PostfixFunction function, string newInfixEquation, out ParseResult result)
 {
     result            = Parser.TryConvertToPostfix(newInfixEquation, function.ArgumentNames, out string postfix);
     function.Equation = postfix;
     function.IsValid  = (result == ParseResult.OK);
     FunctionUpdated?.Invoke(this, function);
 }
        public FunctionGraph CreateGraph(PostfixFunction baseFunction)
        {
            FunctionGraph graph = new FunctionGraph(baseFunction, Color.Red, 1);

            AddGraph(graph);
            return(graph);
        }
        public PostfixFunction CreateFunction(string infixEquation)
        {
            string[]        argumentNames = new string[] { "x" };
            ParseResult     result        = Parser.TryConvertToPostfix(infixEquation, argumentNames, out string postfix);
            PostfixFunction function      = new PostfixFunction(postfix, argumentNames, Field.Variables);

            function.IsValid = (result == ParseResult.OK);
            AddFunction(function);
            return(function);
        }
Exemplo n.º 4
0
        static void TestInput(string input, CalculationContext context)
        {
            string           funcName        = input.Substring(6).Trim(' ');
            FinishedFunction function        = context.FunctionTable[funcName];
            PostfixFunction  postfixFunction = translator.Convert(function);

            Console.WriteLine("Testing functionality: ");
            TestCalculator(postfixCalculator, postfixFunction, context.VariableTable, function.ParameterCount, 10, 1, true);
            TestCalculator(treeCalculator, function, context.VariableTable, function.ParameterCount, 10, 1, true);
            Console.WriteLine("Testing speed: ");
            TestCalculator(postfixCalculator, postfixFunction, context.VariableTable, function.ParameterCount, 100000, 100, false);
            TestCalculator(treeCalculator, function, context.VariableTable, function.ParameterCount, 100000, 100, false);
        }
 public void RemoveFunction(PostfixFunction function)
 {
     Field.RemoveFunction(function);
     FunctionRemoved?.Invoke(this, function);
 }
 public void AddFunction(PostfixFunction function)
 {
     Field.AddFunction(function);
     NewFunctionAdded?.Invoke(this, function);
 }
Exemplo n.º 7
0
 private void OnRemoveFunction(object sender, PostfixFunction function)
 {
 }
Exemplo n.º 8
0
 void OnAddFunction(object sender, PostfixFunction function)
 {
 }
Exemplo n.º 9
0
 private void OnFunctionUpdated(object sender, PostfixFunction e)
 {
 }