CalcExpr.NET
1.0.1
dotnet add package CalcExpr.NET --version 1.0.1
NuGet\Install-Package CalcExpr.NET -Version 1.0.1
<PackageReference Include="CalcExpr.NET" Version="1.0.1" />
<PackageVersion Include="CalcExpr.NET" Version="1.0.1" />
<PackageReference Include="CalcExpr.NET" />
paket add CalcExpr.NET --version 1.0.1
#r "nuget: CalcExpr.NET, 1.0.1"
#:package CalcExpr.NET@1.0.1
#addin nuget:?package=CalcExpr.NET&version=1.0.1
#tool nuget:?package=CalcExpr.NET&version=1.0.1
A .NET 8 math expression parser and calculator library
CalcExpr.NET is a versatile and efficient math expression parsing library developed in C# targeting .NET 8. This library allows you to parse strings containin math expressions into expression trees and then evaluated to calculate the resulting value.
Features
- Expression Parsing: Parse and tokenize mathematical expressions provided as strings.
- Unary Operations: Perfoms unary operations supporting prefixes and postfixes.
- Binary Operations: Perform arithmetic operations such as addition, subtraction, multiplication, division, integer division, and modulus.
- Parentheses Support: Handle nested expressions using parentheses for accurate calculations.
- Variables: Store values in variables and use them in expressions.
- Constants: Store predefined values to be used in expressions.
- Functions: Define and use custom functions using lambda expressions, along with built-in functions in expressions.
- Conditional Function Attributes: Define conditions that parameters must meet before being passed to a function.
- Preprocess Function Attributes: Define preprocesses that are applied to a parameter before being passed to a function.
- Collections: Expressions that are groups containing other functions
- Vectors: Vectors can contain any number of elements in a set order, allowing for non-unique elements.
- Sets: Sets can contain any number of unique elements in an indeterminate order.
- Indexers: An expression to get an element from another expression
Installation
From NuGet Using Visual Studio
- Create or Open your solution/project
- In the Solution Explorer, find the "Dependencies" item in your project
- Right click "Dependencies" and select "Manage NuGet packages..."
- In the "Browse" tab, search for "CalcExpr.NET"
- Install the "CalcExpr.NET" package
From NuGet Using dotnet CLI
- Launch the terminal of your choice
- Navigate to where your csproj file is located
- Enter
dotnet add package CalcExpr.NET
From GitHub Releases
- Go to the Releases section of this repo
- Find the version you want
- Download the CalcExpr.dll file from that release
- Add the file as a reference to your project
Usage
Here's a simple example demonstrating how to use CalcExpr.NET:
using CalcExpr.Parsing;
public class Program
{
public static void Main()
{
// Create a new math parser instance.
Parser parser = new Parser();
// Evaluate an expression.
IExpression result = parser.Parse("2 * -10 + 3").Evaluate();
Console.WriteLine("Result: " + result);
// Displays Result: -17
}
}
Alternatively, a Tokenizer can be provided to specify tokenizing behavior or new parsing rules can be supplied to to modify parsing behavior.
Contributing
We welcome contributions to CalcExpr.NET! Whether it's bug fixes, new features, or improvements to the documentation, your help is greatly appreciated. More information can be found in this file repository's CONTRIBUTING.md file.
How to Contribute
- Fork the Repository: Create a fork of this repository.
- Create a Branch: Make a new branch for your changes based on the
devbranch. - Make Your Changes: Implement your changes and commit them with clear and descriptive commit messages.
- Submit a Pull Request: Open a pull request to the
devbranch of the main repository, detailing the changes you made and why.
License
CalcExpr.NET is released under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- 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.1 | 244 | 12/1/2024 |