a simple cli RPN calculator written in Python
Project description
installation
Requires the latest stable Python version.
pip install kalk
Usage
After installation run kalk from your terminal.
In RPN syntax one would first enter the operands and then the operator:
>>> 1
1
>>> 2
2
>>> +
3
You may also enter the operands and the operator in one line, just use space to separate them:
>>> 41 1 +
42
(tip: the space is not needed when the syntax is not ambiguous.)
Kalk tries to follow Python’s syntax. Similar to Python, ** is the power operator and ^ is bitwise XOR:
>>> 3 3 **
27
>>> 3 3 ^
0
Kalk ignores , (thousands separator) within numbers.
>>> 1,234 1 +
1,235
Most of the functions defined in Python’s math and statistics modules are supported.
>>> 6 lgamma
4.787491742782047
and many more.
You can even do datetime and timedelta calculations:
>>> "2023-03-22" dt
2023-03-22 00:00:00
>>> 2 days 3 hours +
2 days, 3:00:00
>>> -
2023-03-19 21:00:00
Start a substack (a list) with a [ and end it with a ]. Some functions require lists as argument. For example to calculate the distance between two points or sum of some numbers:
>>> [2 -1] [-2 2] dist
5.0
>>> [0 0 0] [1 1 1] dist
1.7320508075688772
>>> [1 1 1] sum
3
Handy operators:
<> swaps the place of the last two values in the stack.
c clears the stack
cp copies the last result to clipboard.
del deletes the last n + 1 values from from the stack with n being the last value in the stack.
e adds Euler’s number to the stack
pi adds the pi constant to the stack
pst pastes the contents of clipboard and evaluates it.
a the last answer
s prints the stack
sto stores the value before the last in storage using the last stack value as the key.
rcl recalls the value in storage using the last stack value as the key.
h prints a list of all operators. (still needs lots of refinements.)
? prints the docstring of the operator given as a string. For example "<>" ? will print the help string on swap. Note that not all functions have documentation yet.
ctrl+c (KeyboardInterrupt) will cancel the current input.
exit will quit the program.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file kalk-0.17.0.tar.gz
.
File metadata
- Download URL: kalk-0.17.0.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae5769b83fb83b5f38b0fe1eb9c5948287f7fbe4e7eab8524e4fa2e8e673427c |
|
MD5 | 2f9a762d03a33ee5befc2cae4d4823f6 |
|
BLAKE2b-256 | d7b8ac4a9253e9f490144fdd6e39aa5fbc31a2fd8a1b35c38fdc447e40515ac6 |
File details
Details for the file kalk-0.17.0-py3-none-any.whl
.
File metadata
- Download URL: kalk-0.17.0-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25aad507455ba45d2f35702087d67be6483db6a548fb3319c2b83907a37ef527 |
|
MD5 | 94d9c50d4effd3145b9fe56bc52ac7e5 |
|
BLAKE2b-256 | ae4b49c20f00e222cbeb6497e7061f7e2415ab65f8baa1df9613b449ad7f0268 |