public VMcode(CodeWindow parent, ContractCollection collection) : base() { this.parent = parent; this.selected = collection.Contracts[0].Name; this.code = new Dictionary <string, Dictionary <string, string> >(); foreach (ContractModel cm in collection.Contracts) { this.code.Add(cm.Name, cm.Functions.ToDictionary(f => f.Name, f => FunctionConverter.Convert(f))); } this.CommandSelectionChanged = new DelegateCommand <object>(this.Select); }
public void MathFunctionReturnsValueAndCalculatesTheSentenceWithUnknown3() { // 2 + atan(x) + x IExpression two = new Constant(2); string function = "ata(x)"; FunctionConverter f = new FunctionConverter(); IExpression value = new VariableX(); IExpression mathFun = new MathFunction(f.Translator(function), value); IExpression x = new VariableX(); IExpression result = new SumExpression(two, mathFun); result = new SumExpression(result, x); Context c = new Context(1); var y = result.Interpret(c); Assert.AreEqual(3.785, y, 4); }
public void MathFunctionReturnsValueAndCalculatesTheSentenceWithFunLog2() { // 2 + cos(-123) + x IExpression two = new Constant(2); string function = "cos(-123)"; FunctionConverter f = new FunctionConverter(); IExpression value = new Constant(f.getValue(function)); IExpression mathFun = new MathFunction(f.Translator(function), value); IExpression x = new VariableX(); IExpression result = new SumExpression(two, mathFun); result = new SumExpression(result, x); Context c = new Context(123); var y = result.Interpret(c); Assert.AreEqual(124.45, y, 2); }
public FunctionParser(FunctionConverter converter) => Converter = converter;