2button, 1op RPN calculator, again
Henry Baker <[email protected]> Tue, 05 May 2026 16:14:07 +0000
| Newsgroups | gmane.comp.mathematics.maxima.general |
|---|---|
| Message-ID | <[email protected]> |
I just realized that this calculator doesn't have any 'regular' buttons at all; the only 2 buttons are the parentheses '(' and ')'.
The '(' button pushes '1' onto the stack; the ')' replaces the top 2 elts of the stack with the single object eml(x,y), where x,y were the top two elements of the stack.
Clearly '(' increments the stack length by 1, while ')' decrements the stack length by 1, so we have a *parenthesis language*, and only properly paired parentheses are allowed.
The stack comes initialized with a single object '1', because *every* legal computation has to start with a push, and the only constant that can be pushed onto the stack is a '1', so we needn't bother with that first push instruction at all !
The number of legal instruction sequences of length 2n is Catalan(n) = binomial(2*n,n)/(n+1).
This means that the fraction of legal instruction sequences approaches zero as the length of the sequence grows, so the bit efficiency of ANY RPN-type representation isn't going to be particularly good.