Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Try this on a non-RPN calculator

  3 + 4   7 + 8
  ----- + -----
  5 + 6   9 + 2


<fraction button> 3 + 4 <down> 5 + 6 <right> + <fraction button> 7 + 8 <down> 9 + 2 =

(19 button presses)

Or:

((3 + 4) / (5 + 6)) + ((7 + 8) / (9 + 2))

(27 button presses)

vs on RPN:

+ / + 3 4 + 5 6 / + 7 8 + 9 2 (I think? I don't use RPN)

(15 button presses)

I guess 19 vs 15 button presses is a tradeoff I'm willing to make for easier understanding.


I'm not familiar with the fraction button. Is this common on calculators? I don't see it on most of the basic function calculators that I look at. Hmm, taking a look around, it looks like it might be present on a lot of scientific calculators, but not the basic calculators I see. I had switched to RPN by the time I started using scientific calculators, so I guess I never became familiar with this button.

Parentheses are common on scientific caclulators and graphing calculators, but as you demonstrate, they add a lot of extra button presses, and you even left out the final "=".

To do this on an RPN calculator, you need nothing beyond the basic 4 functions and the enter key, while you need extra specialized keys like parens or a fraction button to do it on an infix calculator. Taking a look at various infix scientific calculators, they mostly seem to have both parens and a fraction key, so using up the space of 3 keys that an RPN calculator doesn't need and can use for more actual functionality.

Here's how you do it on RPN:

3 <enter> 4 + 5 <enter> 6 + / 7 <enter> 8 + 9 <enter> 2 + / +

You wrote it in Polish notation rather than Reverse Polish Notation, and had left out the enter key that is used as the delimiter between two numbers (pushes a number to the stack, so you can start entering the next number).


RPN:

  3 (enter) 4 +
  5 (enter) 6 +  /
  7 (enter) 8 +
  9 (enter) 2 +  /  +


So 19 presses too, that's got a nice "essential complexity" feel to it.


You can elide one pair of parens.

You forgot the R part of RPN.


Fine, if you can "paint" the full equation on your calculator. But on simpler calculators people may have a hard time getting it right.

  3 + 4 = / ( 5 + 6 = + ( 7 + 8 ) / ( 9 + 2 =




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: