# pol
[![Build Status](https://travis-ci.com/Allain18/pol.svg?branch=master)](https://travis-ci.com/Allain18/pol)
Command line calculator using [reverse polish notation](https://en.wikipedia.org/wiki/Reverse_Polish_notation)
Decimal, hexadecimal, binary and octal number are supported
## Usage
As a command line tool: __pol__
```
~$ pol
Reverse polish notation calculator
>5 10 * dec
50
>0xA 0x6 + hex
0x10
>q //quit the program
~$
```
Instructions are [below](#list-of-commands)
pol can also be use as a module
```python
import rpn_calc
cal = rpn_calculator.Calculator()
cal.evaluate("1 2 + dec")
# print 3
```
## Install
pol can be install from pip
```
pip install rpn-calc
```
If you want to install from a source distribution, extract the tarball and run the following command
```
python setup.py install
```
## Documentation
This README is the Documentation
## [Repo](https://github.com/Allain18/pol)
The code is on github
## Config file
You can write your own command
By default commands from file ~/pol.yml (if exists) are add to the calculator
You can add other files with the flag -f/--file
Config files are written in YAML
### Currently supported parameters
- shortcut: shortcut to commands (see example below)
- rounding: parameter used to round number (default: 0)
### Example of a valid config file
```YAML
shortcut:
- double = 2 * # double the last value of the stack
- 10* = 10 switch ** # same as 10 {x} **
rounding: 3
```
Command must be on the format {name_of_command = command}
## Options
```
usage: pol [-h] [-v] [-l] [--ignore-local-config] [-f FILE [FILE ...]]
A RPN calculator written in python
Support decimal, hexadecimal, binary and octal
optional arguments:
-h, --help show this help message and exit
-v, --version show the version number and exit
-l, --list list all commands available and exit
--ignore-local-config
don't add commands from ~/.pol
-f FILE [FILE ...], --file FILE [FILE ...]
file with customs commands
```
## List of commands
`+` : Take 2 numbers from the stack, add them and put the result in the stack
`-` : Take 2 numbers from the stack, substracte them and put the result in the stack
`*` : Take 2 numbers from the stack, mul them and put the result in the stack
`/` : Take 2 numbers from the stack, divise them and put the result in the stack
`//` : Take 2 numbers from the stack, divise them and put the integer result in the stack
`%` : Take 2 numbers from the stack, divise them and put the remainder in the stack
`**` : Take 2 numbers from the stack, apply power and put the result in the stack
`sqrt` : Replace the last number in the stack with the square root of itself
`exp` : Apply e**x to the last number of the stack
`log10` : Apply log10 to the last number of the stack
`log2` : Apply log2 to the last number of the stack
`ln` : Apply natural logarithm to the last number of the stack
`and` : Take 2 numbers from the stack, apply a bitwise "and" and put the result in the stack
`or` : Take 2 numbers from the stack, apply a bitwise "or" and put the result in the stack
`xor` : Take 2 numbers from the stack, apply a bitwise "xor" and put the result in the stack
`<<` : Take 2 numbers from the stack, apply a left shift and put the result in the stack
`>>` : Take 2 numbers from the stack, apply a right shift and put the result in the stack
`abs` : Make absolute the last value of the stack
`inv` : Inverse the last number of the stack
`neg` : Change the sign of the last number in the stack
`sin` : Replace the last number in the stack with the sine of itself (measured in radians)
`cos` : Replace the last number in the stack with the cosine of itself (measured in radians)
`tan` : Replace the last number in the stack with the tangent of itself (measured in radians)
`asin` : Replace the last number in the stack with the arc sine of itself (measured in radians)
`acos` : Replace the last number in the stack with the arc cosine of itself (measured in radians)
`atan` : Replace the last number in the stack with the arc tangent of itself (measured in radians)
`atan2` : Take 2 numbers from the stack, apply a atan2 function and put the result in the stack
`sinh` : Replace the last number in the stack with the hyperbolic sine of itself
`cosh` : Replace the last number in the stack with the hyperbolic cosine of itself
`tanh` : Replace the last number in the stack with the hyperbolic tangent of itself
`asinh` : Replace the last number in the stack with the asinh of itself
`acosh` : Replace the last number in the stack with the acosh of itself
`atanh` : Replace the last number in the stack with the atanh of itself
`torad` : Convert the last number from degree to radian
`todeg` : Convert the last number from radian to degree
`switch` : Switch the last 2 numbers of the stack
`del` : Delete the last number in the stack
`copy` : Copy the last number of the stack and add it to the stack
`pi` : Add pi to the stack
`tau` : Add tau to the stack
`e` : Add e to the stack
`sum` : Take all the number of the stack and add the sum
`fact` : Replace the last number in the stack with its factorial
`round` : Round the last number in the stack
`ave` : Take all the number of the stack and add the average
`dec` : Print the last number of the stack and remove it
`hex` : Print in hexadecimal format the last number of the stack and remove it
`bin` : Print in binary format the last number of the stack and remove it
`oct` : Print in octal format the last number of the stack and remove it
`ratio` : Print in integer ratio format the last number of the stack and remove it
`s` : Print the stack
`clear` : Empty the stack
`back` : Put back on the stack the last value that was printed
`help` : Print help; Same as pol --list
`q` : Quit the program
## License
MIT
Raw data
{
"_id": null,
"home_page": "https://github.com/Allain18/pol",
"name": "rpn-calc",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "rpn,calculator,reverse polish notation",
"author": "Alain Girard",
"author_email": "alaingirardvd@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/1e/be/c8d1d9d51f96bbe90d3c0802c34244b61ab981d7f3a49b191e1f2f819263/rpn_calc-0.2.3.tar.gz",
"platform": null,
"description": "# pol\n[![Build Status](https://travis-ci.com/Allain18/pol.svg?branch=master)](https://travis-ci.com/Allain18/pol)\n\nCommand line calculator using [reverse polish notation](https://en.wikipedia.org/wiki/Reverse_Polish_notation)\n\nDecimal, hexadecimal, binary and octal number are supported\n\n## Usage\nAs a command line tool: __pol__\n\n```\n~$ pol\nReverse polish notation calculator\n>5 10 * dec\n50\n>0xA 0x6 + hex\n0x10\n>q //quit the program\n~$\n```\n\nInstructions are [below](#list-of-commands)\n\npol can also be use as a module\n```python \nimport rpn_calc\ncal = rpn_calculator.Calculator()\ncal.evaluate(\"1 2 + dec\")\n# print 3\n```\n\n## Install\npol can be install from pip\n```\npip install rpn-calc\n```\nIf you want to install from a source distribution, extract the tarball and run the following command\n```\npython setup.py install\n```\n\n## Documentation\nThis README is the Documentation\n\n## [Repo](https://github.com/Allain18/pol)\nThe code is on github\n\n## Config file\nYou can write your own command\n\nBy default commands from file ~/pol.yml (if exists) are add to the calculator\n\nYou can add other files with the flag -f/--file\n\nConfig files are written in YAML\n\n### Currently supported parameters\n- shortcut: shortcut to commands (see example below)\n- rounding: parameter used to round number (default: 0)\n\n### Example of a valid config file\n```YAML\nshortcut:\n - double = 2 * # double the last value of the stack\n - 10* = 10 switch ** # same as 10 {x} **\nrounding: 3\n```\nCommand must be on the format {name_of_command = command}\n\n## Options\n```\nusage: pol [-h] [-v] [-l] [--ignore-local-config] [-f FILE [FILE ...]]\n\nA RPN calculator written in python\nSupport decimal, hexadecimal, binary and octal\n\noptional arguments:\n -h, --help show this help message and exit\n -v, --version show the version number and exit\n -l, --list list all commands available and exit\n --ignore-local-config\n don't add commands from ~/.pol\n -f FILE [FILE ...], --file FILE [FILE ...]\n file with customs commands\n```\n## List of commands\n`+` : Take 2 numbers from the stack, add them and put the result in the stack\n\n`-` : Take 2 numbers from the stack, substracte them and put the result in the stack\n\n`*` : Take 2 numbers from the stack, mul them and put the result in the stack\n\n`/` : Take 2 numbers from the stack, divise them and put the result in the stack\n\n`//` : Take 2 numbers from the stack, divise them and put the integer result in the stack\n\n`%` : Take 2 numbers from the stack, divise them and put the remainder in the stack\n\n`**` : Take 2 numbers from the stack, apply power and put the result in the stack\n\n`sqrt` : Replace the last number in the stack with the square root of itself\n\n`exp` : Apply e**x to the last number of the stack\n\n`log10` : Apply log10 to the last number of the stack\n\n`log2` : Apply log2 to the last number of the stack\n\n`ln` : Apply natural logarithm to the last number of the stack\n\n`and` : Take 2 numbers from the stack, apply a bitwise \"and\" and put the result in the stack\n\n`or` : Take 2 numbers from the stack, apply a bitwise \"or\" and put the result in the stack\n\n`xor` : Take 2 numbers from the stack, apply a bitwise \"xor\" and put the result in the stack\n\n`<<` : Take 2 numbers from the stack, apply a left shift and put the result in the stack\n\n`>>` : Take 2 numbers from the stack, apply a right shift and put the result in the stack\n\n`abs` : Make absolute the last value of the stack\n\n`inv` : Inverse the last number of the stack\n\n`neg` : Change the sign of the last number in the stack\n\n`sin` : Replace the last number in the stack with the sine of itself (measured in radians)\n\n`cos` : Replace the last number in the stack with the cosine of itself (measured in radians)\n\n`tan` : Replace the last number in the stack with the tangent of itself (measured in radians)\n\n`asin` : Replace the last number in the stack with the arc sine of itself (measured in radians)\n\n`acos` : Replace the last number in the stack with the arc cosine of itself (measured in radians)\n\n`atan` : Replace the last number in the stack with the arc tangent of itself (measured in radians)\n\n`atan2` : Take 2 numbers from the stack, apply a atan2 function and put the result in the stack\n\n`sinh` : Replace the last number in the stack with the hyperbolic sine of itself\n\n`cosh` : Replace the last number in the stack with the hyperbolic cosine of itself\n\n`tanh` : Replace the last number in the stack with the hyperbolic tangent of itself\n\n`asinh` : Replace the last number in the stack with the asinh of itself\n\n`acosh` : Replace the last number in the stack with the acosh of itself\n\n`atanh` : Replace the last number in the stack with the atanh of itself\n\n`torad` : Convert the last number from degree to radian\n\n`todeg` : Convert the last number from radian to degree\n\n`switch` : Switch the last 2 numbers of the stack\n\n`del` : Delete the last number in the stack\n\n`copy` : Copy the last number of the stack and add it to the stack\n\n`pi` : Add pi to the stack\n\n`tau` : Add tau to the stack\n\n`e` : Add e to the stack\n\n`sum` : Take all the number of the stack and add the sum\n\n`fact` : Replace the last number in the stack with its factorial\n\n`round` : Round the last number in the stack\n\n`ave` : Take all the number of the stack and add the average\n\n`dec` : Print the last number of the stack and remove it\n\n`hex` : Print in hexadecimal format the last number of the stack and remove it\n\n`bin` : Print in binary format the last number of the stack and remove it\n\n`oct` : Print in octal format the last number of the stack and remove it\n\n`ratio` : Print in integer ratio format the last number of the stack and remove it\n\n`s` : Print the stack\n\n`clear` : Empty the stack\n\n`back` : Put back on the stack the last value that was printed\n\n`help` : Print help; Same as pol --list\n\n`q` : Quit the program\n\n## License\n\nMIT\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "RPN calculator",
"version": "0.2.3",
"project_urls": {
"Homepage": "https://github.com/Allain18/pol"
},
"split_keywords": [
"rpn",
"calculator",
"reverse polish notation"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c5e6c183b9db691f083e571a259ed56bd12a45c89531def5923b0637303689f2",
"md5": "c42a5ae9113000afd434fdf65b913702",
"sha256": "052b028a62695fcedf306454e30422ddd1ccd2dbddcb7f1c77e835918265f599"
},
"downloads": -1,
"filename": "rpn_calc-0.2.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c42a5ae9113000afd434fdf65b913702",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 8930,
"upload_time": "2023-06-15T08:53:22",
"upload_time_iso_8601": "2023-06-15T08:53:22.463998Z",
"url": "https://files.pythonhosted.org/packages/c5/e6/c183b9db691f083e571a259ed56bd12a45c89531def5923b0637303689f2/rpn_calc-0.2.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1ebec8d1d9d51f96bbe90d3c0802c34244b61ab981d7f3a49b191e1f2f819263",
"md5": "9261ca28efd113c2a5b862047124e86e",
"sha256": "e4c64634ba697b2771c5fe6b45a1c7a9e1ea0de8e138be5b71dbfae658793d70"
},
"downloads": -1,
"filename": "rpn_calc-0.2.3.tar.gz",
"has_sig": false,
"md5_digest": "9261ca28efd113c2a5b862047124e86e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 12249,
"upload_time": "2023-06-15T08:53:24",
"upload_time_iso_8601": "2023-06-15T08:53:24.023952Z",
"url": "https://files.pythonhosted.org/packages/1e/be/c8d1d9d51f96bbe90d3c0802c34244b61ab981d7f3a49b191e1f2f819263/rpn_calc-0.2.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-15 08:53:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Allain18",
"github_project": "pol",
"travis_ci": true,
"coveralls": false,
"github_actions": true,
"lcname": "rpn-calc"
}