Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to change a string to a function name  (Read 1701 times)

0 Members and 1 Guest are viewing this topic.

Aqua_coder

  • Newbie
  • *
  • Posts: 3
    • View Profile
How to change a string to a function name
« 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?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10194
    • View Profile
    • development blog
    • Email
Re: How to change a string to a function name
« Reply #1 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 a try
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

Aqua_coder

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: How to change a string to a function name
« Reply #2 on: February 07, 2022, 07:59:17 pm »
Definitely will give it a try, Thanks for the reply ;D ;D