Reverse Polish Notation

A description of the HP-11C.

dc is an arbitrary precision reverse Polish notation Unix command line calculator. It lacks transcendental functions.

Stack operators:

stack effect dc hp-11c forth factor postscript
( - ) p top of stack always in display dup . dup .
(a - ) n none . . pop
(a b - b a) r x≷y swap swap exch
(a - a a) d ENTER dup dup dup
c none clearstack clear clear
(a b c d - d a b c) R↓ USE: shuffle

-roll
(a b c d - b c d a) R↑ 3 roll USE: shuffle

roll
4 -1 roll

gforth has separate integer and float stacks. I don't know how to take an integer, convert it to float, and put it on the float stack.

The gforth float operators have the same names as the integer operators with an "f" prefix.

gforth floats must always be entered using scientific notation:

$ gforth
Gforth 0.7.3, Copyright (C) 1995-2008 Free Software Foundation, Inc.
Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
Type `bye' to exit
3.14e0 fexp f. 23.1038668587222  ok
bye

Factor can be run from the command line. It has a surprisingly large standard library.

If Factor is installed on a Mac, one can put it in the search PATH:

ln -s /Applications/factor/factor /usr/local/bin/factor

On a Linux system, one may find that there is already a factor command which performs prime factorization.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License