XP is just a number | |
PerlMonks |
Re^3: Reverse Polish Notation Questionby Laurent_R (Canon) |
on May 02, 2015 at 14:48 UTC ( [id://1125443]=note: print w/replies, xml ) | Need Help?? |
Thank you hdb for your comments.
As for the first comment, we have a first degree equation, so, yes, I assumed a straight line on that specific condition, although I was more broadly trying to implement a more general solution. For your second comment, yes, you are absolutely right, calculating the slope would far easier, especially for a linear equation, and I would not even need to painfully consider whether the various calculated values are positive or negative. And even for a polynomial equation, say second or third degree, calculating the slope would narrow down faster on the solution (something similar to the Newton-Raphson method). My error was to initially think it could be done in 15 minutes and 20 lines of code, so I started to code something without carefully thinking of the problem, and discovered only when doing it that it was more complicated than I thought. If I have time this weekend, I'll try to come up with a better design.
Je suis Charlie.
In Section
Seekers of Perl Wisdom
|
|