rpn.js

0.1.0 • Public • Published

rpn.js

Reverse polish notation (RPN).

Converts any string equation (infix notation) to RPN. Calculates RPN notations.

Installation

npm install rpn.js
or
yarn add rpn.js

Usage

See tests directory for more examples.

infixToRPN

import { infixToRPN } from 'rpn.js';

const infix = '(2 + 2) * 2';
const rpn = infixToRPN(infix);

console.log(rpn);
// => [2, 2, 2, '+', '*']

calculateRPN

import { calculateRPN } from 'rpn.js';

const rpn = [2, 2, 2, '+', '*'];
const result = calculateRPN(rpn);

console.log(result);
// => 8

Readme

Keywords

none

Package Sidebar

Install

npm i rpn.js

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

5.74 kB

Total Files

3

Last publish

Collaborators

  • soanvig