-
-
Notifications
You must be signed in to change notification settings - Fork 6
MathExpr
Namespace: StringMath
Assembly: StringMath
Inheritance: Object → MathExpr
References: IMathContext, MathExprExtensions, Precedence
A mathematical expression.
public class MathExprConstructs a MathExpr from a string.
public MathExpr(string text);Parameters
text String: The math expression.
Constructs a MathExpr from an expression tree.
public MathExpr(string text, IMathContext context);Parameters
text String
context IMathContext: The IMathContext in which this expression is evaluated.
The IMathContext in which this expression is evaluated.
public IMathContext Context { get; set; }Property Value
public double Item { get; set; }Property Value
A collection of variable names excluding globals from MathExpr.Variables.
public IReadOnlyCollection<String> LocalVariables { get; set; }Property Value
The result of the expression.
public double Result { get; set; }Property Value
Creates a string representation of the current expression.
public string Text { get; set; }Property Value
A collection of variable names including globals extracted from the MathExpr.Text.
public IReadOnlyCollection<String> Variables { get; set; }Property Value
Add a new unary operator or overwrite an existing operator implementation. Precedence is always Precedence.Prefix.
public static void AddOperator(string name, Func<Double, Double, Double> operation, Precedence? precedence = null);Parameters
name String: The operator's string representation.
operation Func<Double, Double, Double>: The operation to execute for this operator.
precedence Precedence?
public static void AddOperator(string name, Func<Double, Double> operation);Parameters
name String
operation Func<Double, Double>
public static void AddVariable(string name, double value);Parameters
name String
value Double
Compiles a MathExpr into a delegate.
public Func<Double> Compile();Returns
Func: A type safe delegate.
public Func<Double, Double> Compile(string var);Parameters
var String
Returns
public Func<Double, Double, Double> Compile(string var1, string var2);Parameters
var1 String
var2 String
Returns
public Func<Double, Double, Double, Double> Compile(string var1, string var2, string var3);Parameters
var1 String
var2 String
var3 String
Returns
Func<Double, Double, Double, Double>
public Func<Double, Double, Double, Double, Double> Compile(string var1, string var2, string var3, string var4);Parameters
var1 String
var2 String
var3 String
var4 String
Returns
Func<Double, Double, Double, Double, Double>
public Func<Double, Double, Double, Double, Double, Double> Compile(string var1, string var2, string var3, string var4, string var5);Parameters
var1 String
var2 String
var3 String
var4 String
var5 String
Returns
Func<Double, Double, Double, Double, Double, Double>
Add a new unary operator or overwrite an existing operator implementation. Precedence is always Precedence.Prefix.
public MathExpr SetOperator(string name, Func<Double, Double, Double> operation, Precedence? precedence = null);Parameters
name String: The operator's string representation.
operation Func<Double, Double, Double>: The operation to execute for this operator.
precedence Precedence?
Returns
MathExpr: The current math expression.
public MathExpr SetOperator(string name, Func<Double, Double> operation);Parameters
name String
operation Func<Double, Double>
Returns
Substitutes the variable with the given value.
public MathExpr Substitute(string name, double value);Parameters
name String: The name of the variable.
value Double: The new value.
Returns
public override string ToString();Returns