Last active
October 26, 2016 03:33
-
-
Save toptensoftware/5905d16a96fbd62b20aad8039aa3ac73 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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