CalcExpr.NET 1.0.1

dotnet add package CalcExpr.NET --version 1.0.1
                    
NuGet\Install-Package CalcExpr.NET -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="CalcExpr.NET" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CalcExpr.NET" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="CalcExpr.NET" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CalcExpr.NET --version 1.0.1
                    
#r "nuget: CalcExpr.NET, 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.
#:package CalcExpr.NET@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CalcExpr.NET&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=CalcExpr.NET&version=1.0.1
                    
Install as a Cake Tool

License Open Issues GitHub Issues or Pull Requests

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

  1. Create or Open your solution/project
  2. In the Solution Explorer, find the "Dependencies" item in your project
  3. Right click "Dependencies" and select "Manage NuGet packages..."
  4. In the "Browse" tab, search for "CalcExpr.NET"
  5. Install the "CalcExpr.NET" package

From NuGet Using dotnet CLI

  1. Launch the terminal of your choice
  2. Navigate to where your csproj file is located
  3. Enter dotnet add package CalcExpr.NET

From GitHub Releases

  1. Go to the Releases section of this repo
  2. Find the version you want
  3. Download the CalcExpr.dll file from that release
  4. 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

  1. Fork the Repository: Create a fork of this repository.
  2. Create a Branch: Make a new branch for your changes based on the dev branch.
  3. Make Your Changes: Implement your changes and commit them with clear and descriptive commit messages.
  4. Submit a Pull Request: Open a pull request to the dev branch of the main repository, detailing the changes you made and why.

License

CalcExpr.NET is released under the MIT License.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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