Skip to content

Instantly share code, notes, and snippets.

@toptensoftware
Last active October 26, 2016 03:33
Show Gist options
  • Save toptensoftware/5905d16a96fbd62b20aad8039aa3ac73 to your computer and use it in GitHub Desktop.
Save toptensoftware/5905d16a96fbd62b20aad8039aa3ac73 to your computer and use it in GitHub Desktop.
// Expression context
public interface IContext
{
double ResolveVariable(string name);
}
// Represents a variable (or a constant) in an expression. eg: "2 * pi"
public class NodeVariable : Node
{
public NodeVariable(string variableName)
{
_variableName = variableName;
}
string _variableName;
public override double Eval(IContext ctx)
{
return ctx.ResolveVariable(_variableName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment