Giter Site home page Giter Site logo

giorgi / math-expression-evaluator Goto Github PK

View Code? Open in Web Editor NEW
113.0 12.0 29.0 275 KB

A C# library for parsing mathemitical expressions with support for parentheses and variables.

Home Page: https://www.giorgi.dev/net-framework/building-expression-evaluator-with-expression-trees-in-csharp-table-of-contents/

License: Other

C# 100.00%
math-expression-evaluator c-sharp netstandard netstandard20 expression-evaluator

math-expression-evaluator's Introduction

Hi there ๐Ÿ‘‹ I'm Giorgi

Twitter Follow Website Hire Giorgi Sponsor Giorgi

I am a software developer with more than a decade of experience, working mainly with C#, ASP.NET Core, REST, GraphQL, MAUI, Xamarin, Entity Framework Core, AWS, Azure, and SQL Server. I have also worked with many other frameworks and systems such as ASP.NET MVC, ASP.NET Web API, WCF, Avalonia, WinForms, Oracle, and many more. Top 1% on Stack Overflow, member of Top 3% freelance software developers network and InfoQ Editor.

Check out my portfolio or read my blog and Follow me on Twitter and Follow me on InfoQ

GitHub Streak

Shows an illustrated sun in light mode and a moon with stars in dark mode. Shows an illustrated sun in light mode and a moon with stars in dark mode.

math-expression-evaluator's People

Contributors

giorgi avatar thieum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

math-expression-evaluator's Issues

Would love to see support for unary minus

Right now I hacked the code for simple cases by doing this

  private void EvaluateWhile(Func<bool> condition)
    {
        while (condition())
        {
            var right = expressionStack.Pop();
            var left = expressionStack.Count==0 ? Expression.Constant(0m) : expressionStack.Pop();

            expressionStack.Push(((Operation)operatorStack.Pop()).Apply(left, right));
        }
    }

I.e. when the left operand is missing make it 0.

Thank you

For making Advent of Code 2020 - Day 18 easy for me.
Great readable library where I could easily adjust the operator precedence.

Cannot add variables as named arguments

Consider the following code:

        var ev = new ExpressionEvaluator(CultureInfo.InvariantCulture);

        Decimal x = 0;
        Decimal.TryParse(mixedValue.ToString(CultureInfo.InvariantCulture), out x);

        ev.Evaluate(customFormula, x: x);

It fails, saying that there is no a parameter named x, so, how can I add explicitly named variables?

A little suggestion

Hi,

I am using this project for my work.
in short word, it is a great function !
However, I think it will be better if there are more operators like pow(^) absolute(||) etc...

Again, many thanks for this awesome project.

Regional setting

Hi, i have an issue with the regional setting of 2 pc running the same code, the issue is that one of them has configured regional setting as spanish with decimal sign as "." and the other is english with decimal sign as ",". If we use a decimal value on the format "1.002", for example, on the formula the spanish evaluate the formula ok and the english not. There is no way to set culture info to avoid this problem?
Otherwise we have to replace string before evaluate.

Latest nuget package

I had some trouble with the latest nuget package. It does not seem to contain the latest ExpressionEvaluator class. The fixes for Culture support are missing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.