Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/erkin/rpnscm

CLI RPN calculator with REPL and batch evaluation support
https://github.com/erkin/rpnscm

calculator chicken-scheme lisp rpn rpn-calculator scheme

Last synced: 27 days ago
JSON representation

CLI RPN calculator with REPL and batch evaluation support

Awesome Lists containing this project

README

        

* RPNSCM v0.18
A primitive (but future-rich in near future, probably) RPN calculator written in Scheme.
Check the development branch for latest stuff.

This is effectively a toy project for me to hack with CHICKEN Scheme.

** Required extensions
* =srfi-1= (for =zip=)
* =srfi-13= (for =string-pad=, =string-pad-right= & =string-tokenize=)
* =srfi-37= (for =args-fold= & =option=)

** Usage
#+BEGIN_EXAMPLE
rpn -e "EXPRESSION"
#+END_EXAMPLE
See =--help= for options and =--operators=
for a list of operations (and what they do).

*** Example
#+BEGIN_EXAMPLE
% ./rpn -e "4 3 % 7 7 * * 2 / 10 -"
(14)

% ./rpn -i
5 5 +
8 2 *
!
16
^D
(10)

% ./rpn -v -e "4 3 % 7 7 * * 2 / 10 -"
Input: (4 3 % 7 7 * * 2 / 10 -)
0: (3 % 7 7 * * 2 / 10 -) -> 4 -> ()
1: (% 7 7 * * 2 / 10 -) -> 3 -> (4)
2: (7 7 * * 2 / 10 -) -> % -> (4 3)
3: (7 * * 2 / 10 -) -> 7 -> (1)
4: (* * 2 / 10 -) -> 7 -> (1 7)
5: (* 2 / 10 -) -> * -> (1 7 7)
6: (2 / 10 -) -> * -> (7 7)
7: (/ 10 -) -> 2 -> (49)
8: (10 -) -> / -> (49 2)
9: (-) -> 10 -> (24)
10: () -> - -> (24 10)
Output: (14)
#+END_EXAMPLE

** Note
Only integers are supported for the time being.
Inexact numbers get rounded to the nearest exact integer.