All Projects → MathosProject → Mathos Parser

MathosProject / Mathos Parser

Licence: bsd-3-clause
A mathematical expression parser and evaluation library.

Programming Languages

csharp
926 projects

Projects that are alternatives of or similar to Mathos Parser

onvif-discovery
C# .NetStandard 2.0 library to discover ONVIF compliant devices
Stars: ✭ 29 (+11.54%)
Mutual labels:  netcore, netstandard
Nlog.extensions.logging
NLog Provider for Microsoft.Extensions.Logging for .NET Standard libraries and .NET Core applications
Stars: ✭ 323 (+1142.31%)
Mutual labels:  netstandard, netcore
EPPlus4PHP
an easy-to-use excel library for php project which is compiled with peachpie. NOT FOR THE COMMON PHP PROJECT!
Stars: ✭ 15 (-42.31%)
Mutual labels:  netcore, netstandard
AvroConvert
Apache Avro serializer for .NET
Stars: ✭ 44 (+69.23%)
Mutual labels:  netcore, netstandard
Networker
A simple to use TCP and UDP networking library for .NET. Compatible with Unity.
Stars: ✭ 408 (+1469.23%)
Mutual labels:  netstandard, netcore
Cosmos.Identity
A Cosmos storage provider for ASP.NET Core Identity.
Stars: ✭ 26 (+0%)
Mutual labels:  netcore, netstandard
Coding-Standards
Coding Guidelines for C#
Stars: ✭ 125 (+380.77%)
Mutual labels:  netcore, netstandard
ActiveLogin.Identity
Parsing and validation of Swedish identities such as Personal Identity Number (svenskt personnummer) in .NET.
Stars: ✭ 51 (+96.15%)
Mutual labels:  netcore, netstandard
Dbreeze
C# .NET MONO NOSQL ( key value store embedded ) ACID multi-paradigm database management system.
Stars: ✭ 383 (+1373.08%)
Mutual labels:  netstandard, netcore
Gofer.net
Easy C# API for Distributed Background Tasks/Jobs for .NET Core.
Stars: ✭ 383 (+1373.08%)
Mutual labels:  netstandard, netcore
AmiClient
Modern .NET Standard client for accessing the Asterisk AMI protocol using async/await and Reactive Extensions (Rx)
Stars: ✭ 30 (+15.38%)
Mutual labels:  netcore, netstandard
Nlog
NLog - Advanced and Structured Logging for Various .NET Platforms
Stars: ✭ 5,296 (+20269.23%)
Mutual labels:  netstandard, netcore
DotNetDynamicInjector
💉 Dynamically reference external dlls without the need to add them to the project. Leave your project with low dependency and allowing specific dlls according to your business rule or database parameters.
Stars: ✭ 18 (-30.77%)
Mutual labels:  netcore, netstandard
MyDAL
The fastest and best ORM lite on C# for MySQL ! -- 友好, 轻量, 极致性能, 无任何第三方依赖, 持续演进~~
Stars: ✭ 32 (+23.08%)
Mutual labels:  netcore, netstandard
dotnet
.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
Stars: ✭ 865 (+3226.92%)
Mutual labels:  netcore, netstandard
SimCaptcha
✅ 一个简单易用的点触验证码 (前端+后端)
Stars: ✭ 49 (+88.46%)
Mutual labels:  netcore, netstandard
Decor.NET
A simple way to decorate a class with additional functionality using attributes.
Stars: ✭ 29 (+11.54%)
Mutual labels:  netcore, netstandard
AlphaVantage.Net
.Net client library for Alpha Vantage API
Stars: ✭ 65 (+150%)
Mutual labels:  netcore, netstandard
Autofac
An addictive .NET IoC container
Stars: ✭ 3,713 (+14180.77%)
Mutual labels:  netstandard, netcore
Dryioc
DryIoc is fast, small, full-featured IoC Container for .NET
Stars: ✭ 555 (+2034.62%)
Mutual labels:  netstandard, netcore

License NuGet

Mathos Parser

Mathos Parser is a mathematical expression parser and evaluator for the .NET Standard. It can parse various kinds of mathematical expressions out of the box and can be extended with custom functions, operators, and variables.

Documentation and examples are on the wiki.

Features

  • Parse and evaluate mathematical expressions out of the box.
  • Customize and override existing operators, functions, and variables.
  • Culture independent.
  • And much more!

Introduction

Mathos Parser is a part of the Mathos Project, a project that aims to provide useful mathematics APIs and utilities to make life easier. This math parser is fully independent of the Mathos Core Library, so this library achieves powerful math parsing and evaluation without external dependencies.

How to use

Mathos Parser is very easy to use and understand. This section provides examples for the following:

  • Custom variables
  • Custom operators
  • Custom functions
  • Variables through parsing
  • Multi-argument functions

Custom Variables

// Create a parser.
MathParser parser = new MathParser();

// Add a variable.
parser.LocalVariables.Add("a", 25);

// How about another.
parser.LocalVariables.Add("猫", 5);

// Use the variables as you would normally.
Assert.AreEqual(30, parser.Parse("a + 猫"));

Custom Operators

// Create a parser.
MathParser parser = new MathParser();

// Add the custom operator.
parser.Operators.Add("λ", (left, right) => Math.Pow(left, right));

// Evaluate using the new operator.
Assert.AreEqual(Math.Pow(3, 2), parser.Parse("3 λ 2"));

Custom Functions

// Create a parser.
MathParser parser = new MathParser();

// Add the function.
parser.LocalFunctions.Add("timesTwo", inputs => inputs[0] * 2);

// Use the new function.
Assert.AreEqual(8, parser.Parse("timesTwo(4)"));

Variables Through Parsing

// Create a parser.
MathParser parser = new MathParser();

// Define the variable.
parser.ProgrammaticallyParse("let a = 25");

// Evaluation.
Assert.AreEqual(30, parser.Parse("a + 5"));

Multi-Argument Functions

// Create a parser.
MathParser parser = new MathParser();

// Add the function and its implementation.
parser.LocalFunctions.Add("clamp", delegate (double[] inputs)
{
    // The value.
    var value = inputs[0];

    // The maximum value.
    var min = inputs[1];

    // The minimum value.
    var max = inputs[2];

    if (value > max)
        return max;

    if (value < min)
        return min;

    return value;
});

// Use the new function.
Assert.AreEqual(3, parser.Parse("clamp(3,-1,5)"));
Assert.AreEqual(-1, parser.Parse("clamp(-5,-1,5)"));
Assert.AreEqual(5, parser.Parse("clamp(8,-1,5)"));
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].