alandipert / minirpn

Small command-line RPN calculator in C

This URL has Read+Write access

Alan Dipert (author)
Sat Nov 07 14:33:30 -0800 2009
commit  bcd590642d7e2f5976b151913905a18450e7ba43
tree    715791cc969ab3423e21bacd51b2286dfbb28834
parent  2c5571b0dc356547703400ab58fd39f1f2b0e410
name age message
file Makefile Loading commit data...
file README.markdown
file lex.c
file lex.h
file rpn.c
file stack.c
file stack.h
README.markdown

rpn - 4 function CLI RPN calculator

This is a small calculator in C for RPN calculating at the command line. Expressions are read from STDIN. Compile with make and run ./rpn to enter the REPL.

Usage

  • output

    10 .
    
    Prints 10, the value at the top of the stack.
  • addition

    10 2 + .
    
    Prints 12, the sum of 10 and 2.
  • subtraction

    100 50 - .
    
    Prints 50.
  • division

    12 4 / .
    
    Prints 3.
  • multiplication

    3 3 * .
    
    Prints 9.

Note that you can 'peek' the top of the stack anywhere in an expression, ie:

1 2 + . 4 * . 5 + . 3 - .

Prints:

3
12
17
14