Giorgi / PersonalWebsiteComments

0 stars 0 forks source link

net-framework/building-expression-evaluator-with-expression-trees-in-csharp/ #7

Open utterances-bot opened 7 months ago

utterances-bot commented 7 months ago

Building Expression Evaluator with Expression Trees in C# – Improving the Api | Giorgi Dalakishvili | Personal Website

This post is part of a series about building a simple mathematical expression evaluator. For previous posts and full source code see Table of Contents. Introduction

In previous part we added support for variables but it has a big disadvantage: values of the variables are bound by position and not by name. This means that you should pass values for the variables in the same order as they appear in the expression. For example the following test will fail:

https://www.giorgi.dev/net-framework/building-expression-evaluator-with-expression-trees-in-csharp/

greenwiz29 commented 7 months ago

Thanks for your work. This blog has been very informative, and this seems like exactly what my project needs!

Do you have any plans to add additional operators, specifically Power for exponents? I have tried to do so myself, but Parse always crashes when I try to square a variable... It says "The operands for operator 'Power' do not match the parameters of method 'Pow'", which I defined as: new Operation(3, Expression.Power, "Power"). Any idea why this isn't working for me?