Solving a Variable Equation defined by the User

前端 未结 3 517
无人及你
无人及你 2021-02-04 14:28

Answers in C, Python, C++ or Javascript would be very much appreciated. I\'ve read a few books, done all the examples. Now I\'d like to write a simple program. But, I already ra

相关标签:
3条回答
  • 2021-02-04 14:59

    Ffmpeg/libav has a nice simple function evaluator you could use.

    0 讨论(0)
  • 2021-02-04 15:09

    There isn't a simple way to do this in C but I think muParser may be useful to you, it is written in C++ but has C binding. ExprTk is also an option but looks like it is C++ only, on the plus side it looks much easier to get interesting results with.

    Another option may be the Expression Evaluation which is part of Libav. It is in C and the eval.h header has some good descriptions of the interface.

    0 讨论(0)
  • 2021-02-04 15:09

    In compiled languages like C, C++, or Java there is no easy way to do this--you basically have to rewrite a whole compiler (or use an external library with an interpreter). This is only trivial in "scripting" languages like Python and Javascript, which have a function (often called "eval()") that evaluates expressions at runtime. This function is often dangerous, because it can also do things like call functions with side effects.

    0 讨论(0)
提交回复
热议问题