AngouriMath
Substitute
Method with 4 overloads
Substitute(System.String,AngouriMath.Entity.Variable,AngouriMath.Entity)
Summary
Subsitutes a variable by replacing all its occurances with the given value
Parameter "expr"
The expression where to substitute the variablesParameter "var"
A variable to substituteParameter "value"
A value to substitutevar Returns
Expression with substituted the variableExample
Substitution replaces nodes and computes nothing:
Console.WriteLine("x ^ 2 + x".Substitute("x", 3)); Console.WriteLine("x ^ 2 + x".Substitute("x", 3).Evaled);
Prints
3 ^ 2 + 3 12Substitute(System.String,System.ValueTuple{AngouriMath.Entity,AngouriMath.Entity,AngouriMath.Entity,AngouriMath.Entity},System.ValueTuple{AngouriMath.Entity,AngouriMath.Entity,AngouriMath.Entity,AngouriMath.Entity})
Summary
Replaces x.x1 with value.v1 and
x.x2 with value.v2 and
x.x3 with value.v3 and
x.x4 with value.v4
Example
Console.WriteLine("a + b + c + d".Substitute(("a", "b", "c", "d"), (1, 2, 3, 4))); Console.WriteLine("a + b + c + d".Substitute(("a", "b", "c", "d"), (1, 2, 3, 4)).Evaled);
Prints
1 + 2 + 3 + 4 10Substitute(System.String,System.ValueTuple{AngouriMath.Entity,AngouriMath.Entity,AngouriMath.Entity},System.ValueTuple{AngouriMath.Entity,AngouriMath.Entity,AngouriMath.Entity})
Summary
Replaces x.x1 with value.v1 and
x.x2 with value.v2 and
x.x3 with value.v3
Example
Instantiating the coefficients of a quadratic and then solving it:
var quadratic = "a x2 + b x + c".Substitute(("a", "b", "c"), (1, -3, 2)); Console.WriteLine(quadratic); Console.WriteLine(quadratic.SolveEquation("x"));
Prints
1 * x ^ 2 + (-3) * x + 2 { 1, 2 }Substitute(System.String,System.ValueTuple{AngouriMath.Entity,AngouriMath.Entity},System.ValueTuple{AngouriMath.Entity,AngouriMath.Entity})
Summary
Replaces x.x1 with value.v1 and
x.x2 with value.v2
Example
The replacements happen one after another and each sees the result of the last, so
this does not swap two variables — the first substitution putsy where
x was, and the second then rewrites everyy :
Console.WriteLine("x - y".Substitute(("x", "y"), ("y", "x")));
Prints
x - x
Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 4378 pages online