AngouriMath

Navigation

expression from string


← Back to the main page

There are a few ways to parse an expression from string. ## With FromString
using AngouriMath;

var expr = MathS.FromString("1 + 1");
It will throw an exception if input is bad. ## With implicit cast
using AngouriMath;

Entity expr = "1 + 1";
It will also throw an exception in case of bad input. ## With method Parse Unlike others, this one won't throw. However, it returns an object which requries validation:
var expr5 = Parse("a + b").Switch(
    res => res,
    failure => failure.Reason.Switch(
        unknown => throw new("Unknown reason"),
        missingOp => throw new("Missing operator"),
        internalError => throw new("Internal error") 
    )
);


























Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 1534 pages online