Re:The early history of HP calculators
by hota_mazi on Sunday September 10, 2017 @10:57PM
(#15215570)
It works here because the expression is simple. You only have four variables on the stack (maybe more in later models that I'm not aware of) and for those, you are screwed if you just push things on the stack in reading order:
2 * (3 + (4 + (5 + (6 + 7))
The only way to process this is to determine the most nested expression and start there: 6 7 + 5 + 4 + 3 + 2 *
... you get the idea.Expand this expression with multiple deeply nested parens and the limitations of RPN become very obvious.
Re:The early history of HP calculators
by ScottBurson on Monday September 11, 2017 @01:52AM
(#15216270)
I'm pretty sure the more recent, higher-end RPN calculators have lots more than 4 stack slots.
4 is usually enough in practice anyway. Your example is artificial.
Besides, are you sure your infix calculator will accept this deep a nesting of parentheses? The TI models that were contemporary with the early HPs certainly wouldn't!
When you encounter an open parenthesis, then you just push the following number onto the stack, when you encounter a close parenthesis, you just perform the relevant arithmetic operation.
For the example
we can do this