math - Implementing function trees in C# -


Imagine that you have a number of nodes that can be either operator nodes ( Unary or binary operators), or terminal nodes (static).

I have just started putting a finger on the keyboard and I have a small snag I have a node interface, operator: node , BinaryOperator: Operator , UnaryOperator: operator and created Terminal: node build.

And here I am with my problem. Can I now create a separate square for each closest function? Do I have a SinOperator: UnaryOperator and CosApterator: aun ary operator and AddOperator: BinaryOperator and so on?

Alternatively, I can leave it only on binary and unit operators and pass it in a representative which evaluates the evaluation of the node, depending on the value of its hair nodes.

  var sinOperator = New UnaryOperator (childNode, Representative) {return mathematics.sine (childNode.GetValue ());});   

But then there really is nothing that can be prevented from inserting all kinds of crazy stuff from the reporter, completely dismantling the full concept of being an operator.

Note: Yes I have realized that there are only a few operators (+ - * / ^ â ????), and these sins / cos are actually < Strong> function . But for the purpose of this project, we can assume that it is an operator

how will you create it in C #?

Why do not you look at work? This is an existing model of (and the entire .NET language) in C #.

Here you have been implemented using Linq.Expressions (you can see how it manages operators, signs, cognizes etc ...) < / Html>

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -