Equation Parsing Library C++ [closed]

2019-03-12 14:05发布

I'm sure there must be something like this somewhere but I can't seem to find anything useful on here or Google. I had hoped Boost might have something but alas not.

What I'm after is a lightweight library that can take a string from the user, for example "y=2x+3" and parse it returning an object or function which returns y when given x.

Can anybody recommend something for this? (Worst case I could write one myself but no point reinventing the wheel and all.)

Things which can be assumed if necessary;

  • Preset variable names
  • Number of variables fixed

1条回答
干净又极端
2楼-- · 2019-03-12 14:50

MuParser is all you ever could wish for. You can even define custom operators, store and evaluate the expressions in binary form, etc... Written in C++, bindings for C and C# (and maybe even other languages).

查看更多
登录 后发表回答