Dubacik22.Equationer 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Dubacik22.Equationer --version 1.0.1
NuGet\Install-Package Dubacik22.Equationer -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Dubacik22.Equationer" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dubacik22.Equationer --version 1.0.1
#r "nuget: Dubacik22.Equationer, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Dubacik22.Equationer as a Cake Addin
#addin nuget:?package=Dubacik22.Equationer&version=1.0.1

// Install Dubacik22.Equationer as a Cake Tool
#tool nuget:?package=Dubacik22.Equationer&version=1.0.1

formula parsing library.

this library can parse string equations and recognize user functions and user variables like: "func1(null, 1, var0, func2(var1, some.other.var2)+'str', -60)" where va0, var1, some.other.var2 are recognized as variables func1, func2 are recognized as functions and 'str' is recognized as string constant. allso -60 as bool constant

returns ICalculatable which has GetCalculatedValue() to get the result

if there is a variable in the formula, then the parser gets it using the "FetchVariable" fetcher. this fetcher must return the IGetVariable class, which must have the property Variable of type object, but it is useful if it returns a double, bool or string. if there is a function in the formula, then the parser gets it using the "FetchFunction" fetcher. this fetcher must return an IFunction class which must have a double Calculate(IEnumerable<double> arguments)

when string "(4>5)==false" is parsed, and GetCalculatedValue() of resulting ICalculatable is called, we gets true as result. the GetCalculatedValue() of Calculatable calls Variable getter for each IGetVariable and Calculate method for each IFunction class and returns resulting object.

example:

public class DummyValue : IGetVariable
{
    public object Variable { get => double.NaN; }
}
public class DummyFunc : IFunction
{
    public object Calculate(IEnumerable<object> arguments)
    {
        return arguments.First();
    }
}
public class Test()
{
    var parser = new EquationParser
    {
        FetchFunction = name => new DummyFunc(),
        FetchVariable = name => new DummyValue(),
    }
    parser.Parse("(v) ? 1 : (v > 1) ? 's' : f(v, 2)");
    parser.Parse("(4>5)==false");
    parser.Parse("(true) and ('qw' == 'ivan')");
    parser.Parse("(true) ? (4 gteq 4) ? 1 : 2 : 3");
    parser.Parse("func1(null, 1, #var0, func2(var1, some.other.var2)+'_a', -60)");
}
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.19 190 11/21/2023
1.0.18 82 11/21/2023
1.0.16 165 7/28/2023
1.0.15 135 7/18/2023
1.0.14 160 7/4/2023
1.0.13 176 6/28/2023
1.0.12 148 6/27/2023
1.0.11 142 6/27/2023
1.0.10 147 6/20/2023
1.0.9 153 6/19/2023
1.0.8 148 6/13/2023
1.0.7 140 6/5/2023
1.0.6 161 5/31/2023
1.0.5 423 9/17/2022
1.0.4 390 8/16/2022
1.0.3 436 3/4/2022
1.0.2 431 2/4/2022
1.0.1 5,224 11/24/2021

1.0.1