Hey,
I'm looking at creating a set of math expression functions. Here's a quick example of what i want:
Code:
int i = 0;
mathexpr em = MathCreate(1); //Creates a unique handle, sets the initial value to 1
MathAdd(em,10); //Makes the expression add 10 to the value. Not calculating yet.
MathSub(em,6); //Makes the expression subtract 5 from the value. Not calculating yet.
i = MathEval(em); //Will evaluate the expression "1+10-6" returning 5.
MathDestroy(em); //Destroys an expression, releasing it's handle, and freeing the memory used.
//Other functions would include
MathSet(em,i); //Sets the value of the expression to i, clearing the whole expression.
MathDiv(em,i); //Divisions
MathMult(em,i); //Multiplication
MathOr(em,i); //Bitwise Or Operation
MathAnd(em,i); //Bitwise And Operation
MathXor(em,i); //Bitwise Xor Operation
MathPow(em,i); //Would add pow(MathEval(em),i)
//This is just the things i could brainstorm, any math function i deem usefull should be added.
//Also, if possible the different Math* should return an id, then a function called MathRemove(m)
//could be used to remove a certain step from an expression. Example from above:
int i = 0;
mathstep m = 0;
mathexpr em = MathCreate(1); //Creates a unique handle, sets the initial value to 1
m = MathAdd(em,10); //Makes the expression add 10 to the value.
MathSub(em,6); //Makes the expression subtract 5 from the value.
MathRemove(em,m); //Removes the "+10" part of the expression, leaving "1-6".
i = MathEval(em); //Will evaluate the expression "1-6" returning -5.
MathDestroy(em); //Destroys an expression, releasing it's handle, and freeing the memory used.
I hope that example states well enough what i want to do. To me, it sounds rather simple to do, but problem is, i don't really know where to start. I'm very new to c programming, and i've only made a handfull small things so far. Mainly using MSDN to lookup, and work from examples.
Please know that i'm not asking for code, i'm asking for knowledge, ideas, usefull reading and really any usefull info.