Skip to content

Instantly share code, notes, and snippets.

@davidelettieri
Created April 17, 2020 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidelettieri/f041f3b4a3a17a72eec21049a6973e98 to your computer and use it in GitHub Desktop.
Save davidelettieri/f041f3b4a3a17a72eec21049a6973e98 to your computer and use it in GitHub Desktop.
public interface INode
{
double Eval(Dictionary<char, double> variablesValue);
}
public class AddNode : INode
{
private readonly INode _left;
private readonly INode _right;
public AddNode(INode left, INode right)
{
_left = left;
_right = right;
}
public double Eval(Dictionary<char, double> variablesValue) => _left.Eval(variablesValue) + _right.Eval(variablesValue);
public override string ToString()
{
return $"Add({_left},{_right})";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment