Stack-Based Arithmetic on Linux
I’ve just discovered that you can run ghostscript in a no display mode from the console and use the interpreter as an environment to perform stack-based arithmetic.
tim@withnail:~$ gsnd
GPL Ghostscript 8.01 (2004-01-30)
Copyright (C) 2004 artofcode LLC, Benicia, CA. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
GS>2
GS<1>3
GS<2>stack
3
2
GS<2>add
GS<1>stack
5
GS<1>10
GS<2>mul
GS<1>stack
50
GS<1>quit
stack displays the stack, entering a number pushes it onto the stack, pop removes the top item, add / div / mul / sub remove the top two operands, and add them / divide them / multiply them / subtract second from first then return the result to the stack.
One for computer science geeks only.