Jump to content
  • Advertisement
Sign in to follow this  
Deltasquadron2

Store Mathematical expression into a String

This topic is 4356 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone know how to put a mathematical expression into a string, including variables, and have it parsed? In otherwords, I want to put my math into an external file and then be able to read it back in. I'm working with C#. Thanks! [Edited by - Deltasquadron2 on August 19, 2006 11:34:30 PM]

Share this post


Link to post
Share on other sites
Advertisement
A string would be an extremely bad representation for an expression. As I think Zahlman is refering to, you should study some of the technologies used for parsing normal programming/scripting languages. After that, depending on what you need to do, you need to look up some algorithms used for this kind of stuff. Or if you need some fun, try to make them yourself, then look up the real algorithms to see how much you can improve yours.

Share this post


Link to post
Share on other sites
Simple method 1: mark your entire expression tree as serializable, write it to file (results in a binary file).

Simple method 2: mark your entire expression tree as XML-serializable, write it to file (results in an XML file).

Harder method 1: perform a prefix-traversal of your expression tree with spaces between each node (this will result in prefix polish notation storage). Reloading is then a simple recursive algorithm.

Harder method 2: reuse or implement a full-scale parser for a script language that suits your needs.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!