rpn-infix-postfix

1.0.5 • Public • Published

RPN


Jan Łukasiewicz (Inventor of RPN)

Infix to postfix

Reverse Polish notation (RPN), also known as Polish postfix notation or simply postfix notation, is a mathematical notation in which operators follow their operands, in contrast to Polish notation (PN), in which operators precede their operands. It does not need any parentheses as long as each operator has a fixed number of operands. The description "Polish" refers to the nationality of logician Jan Łukasiewicz, who invented Polish notation in 1924     -Wikipedia


Npm

Downloading

$npm i rpn-infix-postfix

Usage

const {  
  infixToPostfix,
  postfixSolver,
  solve,
  Stack }  = require('rpn-infix-postfix');
 
console.log(solve('1 + 2 * 9' )); // result => 19
console.log(
  infixToPostfix('1*(4-2)', new Stack(100)).join('')
); // result => 142-*

Downloading (via git)

git clone https://github.com/SC0d3r/RPN-infix-to-postfix.git RPN

cli Usage

after cloning go to directory and then run the following command

$node index.js '1* ( 2 + 3)'
 
    > 5 [result]

only postfix version

$node index.js '1* ( 2 + 3)' -postfix
 
   > 123+* [result]

Test

run tests with

$npm test

Readme

Keywords

Package Sidebar

Install

npm i rpn-infix-postfix

Weekly Downloads

0

Version

1.0.5

License

MIT

Last publish

Collaborators

  • sc0d3r