in reply to Evaluate arbitrary boolean expressions
Example using stack: (2+3)*5 results in: push 2, push 3, add, push 5, multiply This requires an op precedence table.
I think you are better off with some form of Perl eval if the actual equation is unknown until runtime.
As another technique, for 8 variables, you can make an array of say 256 entries, use one bit for each variable, precalculate the results for the 8 variables and use a simple lookup table for the result.
This is also possible with a Perl hash table. Just calculate values where the 8 or whatever variables describe a "true" result.
|
|---|