{"id":17358281,"url":"https://github.com/sklose/ncalc2","last_synced_at":"2025-04-10T06:36:25.814Z","repository":{"id":5608730,"uuid":"50044773","full_name":"sklose/NCalc2","owner":"sklose","description":"expression evaluator for .NET with built-in compiler","archived":false,"fork":false,"pushed_at":"2024-09-29T05:07:44.000Z","size":1681,"stargazers_count":170,"open_issues_count":29,"forks_count":58,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-10-30T03:43:08.386Z","etag":null,"topics":["c-sharp","dotnet-core","dotnet-standard","dotnetcore","expression-evaluator","expression-parser"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"tyrone-sudeium/NCalc","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sklose.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-20T16:53:09.000Z","updated_at":"2024-10-25T03:09:57.000Z","dependencies_parsed_at":"2024-02-07T01:30:45.600Z","dependency_job_id":"b9066d71-b6eb-42a5-bda3-e0eb70395b00","html_url":"https://github.com/sklose/NCalc2","commit_stats":{"total_commits":105,"total_committers":24,"mean_commits":4.375,"dds":0.5809523809523809,"last_synced_commit":"7fc9f67b581fce3cd94cfc6e49136e0344e75889"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sklose%2FNCalc2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sklose%2FNCalc2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sklose%2FNCalc2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sklose%2FNCalc2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sklose","download_url":"https://codeload.github.com/sklose/NCalc2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248170637,"owners_count":21059222,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-sharp","dotnet-core","dotnet-standard","dotnetcore","expression-evaluator","expression-parser"],"created_at":"2024-10-15T19:04:57.286Z","updated_at":"2025-04-10T06:36:25.781Z","avatar_url":"https://github.com/sklose.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NCalc\n\n[![Build status](https://ci.appveyor.com/api/projects/status/ugw4wg1iws3far9m?svg=true)](https://ci.appveyor.com/project/sklose/ncalc2) [![NuGet](https://img.shields.io/nuget/v/CoreCLR-NCalc.svg)](https://www.nuget.org/packages/CoreCLR-NCalc) [![NuGet](https://img.shields.io/nuget/dt/CoreCLR-NCalc.svg)](https://www.nuget.org/packages/CoreCLR-NCalc)\n\n| :warning: 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\n| --- |\n\nA clone of NCalc from http://ncalc.codeplex.com/ with the following changes:\n- added support for .NET Standard 2.0+\n- added compilation of expressions to actual CLR lambdas\n\n# Installation\n\nSimply install the package via NuGet\n\n```powershell\nPM\u003e Install-Package CoreCLR-NCalc\n```\n\n# Creating Lambdas\n\n## Simple Expressions\n\n```csharp\nvar expr = new Expression(\"1 + 2\");\nFunc\u003cint\u003e f = expr.ToLambda\u003cint\u003e();\nConsole.WriteLine(f()); // will print 3\n```\n\n## Expressions with Functions and Parameters\n\n```csharp\nclass ExpressionContext\n{\n  public int Param1 { get; set; }\n  public string Param2 { get; set; }\n  \n  public int Foo(int a, int b)\n  {\n    return a + b;\n  }\n}\n\nvar expr = new Expression(\"Foo([Param1], 2) = 4 \u0026\u0026 [Param2] = 'test'\");\nFunc\u003cExpressionContext, bool\u003e f = expr.ToLambda\u003cExpressionContext, bool\u003e();\n\nvar context = new ExpressionContext { Param1 = 2, Param2 = \"test\" };\nConsole.WriteLine(f(context)); // will print True\n```\n\n## Performance Comparison\n\nThe 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%).\n\n| Formula  | Description | Expression Evaluations / sec | Lambda Evaluations / sec | Speedup |\n| ------------- | ------------- | ------------- | ------------- | ------------- |\n| (4 * 12 / 7) + ((9 * 2) % 8)  | Simple Arithmetics | 474,247.87 | 32,691,490.41 | 6,793.33% |\n| 5 * 2 = 2 * 5 \u0026\u0026 (1 / 3.0) * 3 = 1  | Simple Arithmetics | 276,226.31 | 93,222,709.05 | 33,648.67% |\n| [Param1] * 7 + [Param2]  | Constant Values| 707,493.27 | 21,766,101.47 | 2,976.51% |\n| [Param1] * 7 + [Param2]  | Dynamic Values | 582,832.10 | 21,400,445.13 | 3,571.80% |\n| Foo([Param1] * 7, [Param2])  | Dynamic Values and Function Call | 594,259.69 | 17,209,334.34 | 2,795.93% |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsklose%2Fncalc2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsklose%2Fncalc2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsklose%2Fncalc2/lists"}