M
M
mIka012022-04-15 10:07:23
Mathematics
mIka01, 2022-04-15 10:07:23

How to convert a formula entered by the user into code?

Hello, how to convert the formula entered by the user into code?
There is a task. A person enters some formula with 2 unknowns (let's say x, y ) and you need to enumerate these unknowns with recording the values ​​of the equation.

Example.
What the person enters.
A person enters a formula in the console What, in theory, should become.
Math.sqrt(x * 5) + Math.Pow(y, 2) - 4

double formula = Math.sqrt(x * 5) + Math.Pow(y, 2) - 4;
// x , y - перебирается по определенным законам.


I assume that such a task is not new, and in order not to reinvent the wheel, tell me, maybe there are already ready-made solutions?

Thank you in advance for your response.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
HemulGM, 2022-04-15
@HemulGM

https://habr.com/ru/post/553310/

R
Roman, 2022-04-15
@yarosroman

Dynamic compilation
https://stackoverflow.com/questions/826398/is-it-p...
see all the answers there, you can compile the assembly into memory and pull methods through reflection.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question