I googled and came up blank – so it’s time to test the good folks at SO again! 🙂
Can anyone recommend an open source library (pref for .NET) that parses and calculates mathematical expressions?
e.g. input expression = "2+(n-1)*4", parameter key/value n=2, output = 6.
I would take a look at NCalc. Here is a description of the project:
If this is too complex for your purpose, you can take a look at any "parser generator" for C#. These tools allow you to specify the grammar of your expression and generate code that will parse it. Writing parser for numerica expressions should be pretty straightforward. See for example
See for example FsLex Sample by Chris Smith