Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equation Parsing Library C++ [closed]

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
like image 574
Dan Avatar asked Feb 29 '12 17:02

Dan


1 Answers

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).

like image 136
rubenvb Avatar answered Oct 16 '22 16:10

rubenvb