Skip to content

Instantly share code, notes, and snippets.

@shalvah
shalvah / rpn-parser.js
Last active October 22, 2018 19:21
Tokenize and convert a math expression from infix to postfix in Javascript
function parse(inp){
var outQueue=[];
var opStack=[];
Array.prototype.peek = function() {
return this.slice(-1)[0];
};
var assoc = {
"^" : "right",