rpncalc v1.0.1
Interactive code:
https://replit.com/@alexandresouto/rpncalc#main.cr
A Reverse Polish Notation Calculator, with expression/macro functionality.
All Operators:
Math (1 operator): sq sqrt [ln|log] [neg|opo] inv floor ceil
Math (2 operators): [+] [-] [*] [/] [**|pow] [%|mod] log_
Math (N operators): sum mult max min
Random Numbers: 'rand' returns a random float 0~1, 'randi' returns a random integer 0~(N-1)
Stack Handling: dup cpy cpyn cpyto pop del deln [clr|clear] [swp|swap]
Qtty of numbers in the line until the comma: [,] Stack size: [.|qtt|qtty]
Create Expression: { <w1> <w2> <w3> ... } <name>
List Expressions: expr or expri(for indexes) Delete Expression: <N> delxpr Repeat <w1> N times: repeat_<w1>
Execute <w1> or <w2> conditionally: doif_<w1>_<w2>
Set a variable <w1>: set_<w1> Example: 5 set_x Help: [help|cmds]
Exit: [exit|out]
There are two programming Operators: repeat_value1 and doif_value1_value2
Values can be Numeric Values, Operators, or Expressions
repeat_value1 consumes the last value as a quantity N And apply value1 N times in the stack
doif_value1_value2 consumes the last value as a condition Any positive number is considered true, otherwise it is considered false if true apply value1 on the stack, if false apply value2 on the stack _value2 is optional _value1 can be omited with a doif__value2
Definining expressions example:
Type "{ 2 * } double" to define the "double" expression With the stack "[5]", typing "double" results in "[10]" With the stack "[10]", typing "8 + double" results in "[36]"rpncalc
- 0
- 0
- 0
- 0
- 0
- over 1 year ago
- April 18, 2022
Thu, 07 Nov 2024 08:52:22 GMT