SFML community forums

General => SFML projects => Topic started by: Aqua_coder on February 06, 2022, 10:29:44 am

Title: How to change a string to a function name
Post by: Aqua_coder on February 06, 2022, 10:29:44 am
soo recently I was making a math plotter, and I managed to make functions like the parabola, the sine function and something like that. But I don't know how to change the string into a desiarable function type,

For example If I want a function of x^2 and enter a string through the function parameter, How do I interpret it through the vertex array?
Title: Re: How to change a string to a function name
Post by: eXpl0it3r on February 07, 2022, 08:18:23 am
You'll need to write a parser of some sort.
Depending on the complexity and desired notation, you could give the Shunting-yard algorithm (https://en.wikipedia.org/wiki/Shunting-yard_algorithm) a try
Title: Re: How to change a string to a function name
Post by: Aqua_coder on February 07, 2022, 07:59:17 pm
Definitely will give it a try, Thanks for the reply ;D ;D