https://github.com/basemax/infix2postfix-evaluator
A Javascript Implementation of an Infix to Postfix Evaluator. It can evaluate any infix expression and convert it to postfix expression.
https://github.com/basemax/infix2postfix-evaluator
evaluator expression expression-evaluator expression-parser expressions infix javascript js math-evaluator math-parser parser postfix
Last synced: 5 months ago
JSON representation
A Javascript Implementation of an Infix to Postfix Evaluator. It can evaluate any infix expression and convert it to postfix expression.
- Host: GitHub
- URL: https://github.com/basemax/infix2postfix-evaluator
- Owner: BaseMax
- License: gpl-3.0
- Created: 2022-11-05T13:22:29.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-03T17:19:08.000Z (almost 3 years ago)
- Last Synced: 2025-09-06T12:56:16.699Z (5 months ago)
- Topics: evaluator, expression, expression-evaluator, expression-parser, expressions, infix, javascript, js, math-evaluator, math-parser, parser, postfix
- Language: JavaScript
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Infix t Postfix Evaluator
A Javascript Implementation of an Infix to Postfix Evaluator. It can evaluate any infix expression and convert it to postfix expression.
### Infix
Infix notation is the most common way of writing arithmetic expressions. It is known as standard notation in some countries. The following example shows an infix expression and its equivalent postfix expression:
```text
2 + 3 * 4
2 3 4 * +
```
### Postfix
Postfix notation is a way of writing arithmetic expressions without using parentheses that specify the order of operations. It is known as Reverse Polish notation (RPN) in some countries. The following example shows a postfix expression and its equivalent infix expression:
```text
2 3 4 * +
2 + 3 * 4
```
## Examples
```javascript
console.log(evaluate_postfix(convert_infix_to_postfix("2+3*4"), {}));
// 14
console.log(evaluate_postfix([ '2', '3', '4', '*', '+' ], {}));
// 14
console.log(evaluate_postfix([
"a", "b", "/", "c", "-", "d", "e", "*", "+", "a", "c", "*", "-"
], { a: 4, b: 2, c: 3, d: 2, e: 5}));
// -3
```
Copyright (c) 2022, Max Base