All Projects → sklose → NCalc2

sklose / NCalc2

Licence: MIT License
GitHub clone of NCalc from http://ncalc.codeplex.com/

Programming Languages

C#
18002 projects
GAP
223 projects

Projects that are alternatives of or similar to NCalc2

AsteroidsWasm
Collection of applications based on a single C# .NET Standard project running in: Blazor Client (WebAssembly), Blazor Server, Electron, WPF, WinForms, Xamarin
Stars: ✭ 136 (+40.21%)
Mutual labels:  dotnetcore, dotnet-standard
java.math.expression.parser
java math expression parser is faster than JEP
Stars: ✭ 25 (-74.23%)
Mutual labels:  expression-parser, expression-evaluator
Dot-Net-Ecosystem
Welcome to the GitHub repository of the .NET Ecosystem. This repository contains the examples for the Pluralsight course: The .NET Ecosystem: The Big Picture. You can download a copy and follow along in the course.
Stars: ✭ 34 (-64.95%)
Mutual labels:  dotnetcore, dotnet-standard
Rafty
Implementation of RAFT consensus in .NET core
Stars: ✭ 182 (+87.63%)
Mutual labels:  dotnetcore, dotnet-standard
Waveshare.EPaperDisplay
.Net Core Library to show images on Waveshare E-Paper Displays
Stars: ✭ 17 (-82.47%)
Mutual labels:  dotnetcore, dotnet-standard
Corehook
A library that simplifies intercepting application function calls using managed code and the .NET Core runtime
Stars: ✭ 191 (+96.91%)
Mutual labels:  dotnetcore, dotnet-standard
Capstone.NET
.NET Core and .NET Framework binding for the Capstone Disassembly Framework
Stars: ✭ 108 (+11.34%)
Mutual labels:  dotnetcore, dotnet-standard
Sio.core
✔ [ SIOC ] Swastika I/O Core is an all in one platform (e.g CMS, eCommerce, Forum, Q&A, CRM...) ASP.NET Core / Dotnet Core System based on SIOH Framework.
Stars: ✭ 121 (+24.74%)
Mutual labels:  dotnetcore, dotnet-standard
elgamalext
Extension for the .NET Framework cryptography subsystem, which introduces the ElGamal public key cryptosystem with support for homomorphic multiplication.
Stars: ✭ 14 (-85.57%)
Mutual labels:  dotnetcore, dotnet-standard
string-math
Evaluates a math expression from a string. Supports variables and custom operators.
Stars: ✭ 14 (-85.57%)
Mutual labels:  expression-parser, expression-evaluator
Dotnet Etcd
A C# .NET (dotnet) GRPC client for etcd v3 +
Stars: ✭ 157 (+61.86%)
Mutual labels:  dotnetcore, dotnet-standard
pratt-calculator
A very simple expression evaluator written using a Pratt Parser
Stars: ✭ 22 (-77.32%)
Mutual labels:  expression-parser, expression-evaluator
Appmetrics
App Metrics is an open-source and cross-platform .NET library used to record and report metrics within an application.
Stars: ✭ 1,986 (+1947.42%)
Mutual labels:  dotnetcore, dotnet-standard
Sharpsnmplib
Sharp SNMP Library- Open Source SNMP for .NET and Mono
Stars: ✭ 247 (+154.64%)
Mutual labels:  dotnetcore, dotnet-standard
Wopihost
ASP.NET Core MVC implementation of the WOPI protocol. Enables integration with WOPI clients such as Office Online Server.
Stars: ✭ 132 (+36.08%)
Mutual labels:  dotnetcore, dotnet-standard
DNZ.SEOChecker
SEO Checker and Recommander Plugin (like wordpress Yoast) for ASP.NET Core.
Stars: ✭ 18 (-81.44%)
Mutual labels:  dotnetcore, dotnet-standard
Veil
A template renderer / view engine for .NET
Stars: ✭ 23 (-76.29%)
Mutual labels:  dotnetcore, dotnet-standard
Raft.net
Implementation of RAFT distributed consensus algorithm among TCP Peers on .NET / .NETStandard / .NETCore / dotnet
Stars: ✭ 112 (+15.46%)
Mutual labels:  dotnetcore, dotnet-standard
ReflectionToIL
A demonstration and benchmark of different approaches to load closure fields using reflection and dynamic code generation
Stars: ✭ 30 (-69.07%)
Mutual labels:  dotnetcore, dotnet-standard
King.Service
Task scheduling for .NET
Stars: ✭ 34 (-64.95%)
Mutual labels:  dotnetcore, dotnet-standard

NCalc

Build status NuGet NuGet

⚠️ This repository is currently only passively maintained. If there are fully fledged PRs, I will occasional merge those in and publish new versions. If you would like to become a maintainer and work on some of the open issues, please reply here https://github.com/sklose/NCalc2/issues/61

A clone of NCalc from http://ncalc.codeplex.com/ with the following changes:

  • added support for CoreCLR (.NET Standard 1.3+)
  • embedded portable version of Antlr (no extra library/dependency required)
  • added compilation of expressions to actual CLR lambdas

Installation

Simply install the package via NuGet

PM> Install-Package CoreCLR-NCalc

Creating Lambdas

Simple Expressions

var expr = new Expression("1 + 2");
Func<int> f = expr.ToLambda<int>();
Console.WriteLine(f()); // will print 3

Expressions with Functions and Parameters

class ExpressionContext
{
  public int Param1 { get; set; }
  public string Param2 { get; set; }
  
  public int Foo(int a, int b)
  {
    return a + b;
  }
}

var expr = new Expression("Foo([Param1], 2) = 4 && [Param2] = 'test'");
Func<ExpressionContext, bool> f = expr.ToLambda<ExpressionContext, bool>();

var context = new ExpressionContext { Param1 = 2, Param2 = "test" };
Console.WriteLine(f(context)); // will print True

Performance Comparison

The measurements were done during CI runs on AppVeyor and fluctuate a lot in between runs, but the speedup is consistently in the thousands of percent range. The speedup measured on actual hardware was even higher (between 10,000% and 35,000%).

Formula Description Expression Evaluations / sec Lambda Evaluations / sec Speedup
(4 * 12 / 7) + ((9 * 2) % 8) Simple Arithmetics 474,247.87 32,691,490.41 6,793.33%
5 * 2 = 2 * 5 && (1 / 3.0) * 3 = 1 Simple Arithmetics 276,226.31 93,222,709.05 33,648.67%
[Param1] * 7 + [Param2] Constant Values 707,493.27 21,766,101.47 2,976.51%
[Param1] * 7 + [Param2] Dynamic Values 582,832.10 21,400,445.13 3,571.80%
Foo([Param1] * 7, [Param2]) Dynamic Values and Function Call 594,259.69 17,209,334.34 2,795.93%
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].