From 1ef6792a9f2144ab350aa4b9f403f1f9b528c093 Mon Sep 17 00:00:00 2001 From: Rohit Tanwar <31792358+kriadmin@users.noreply.github.com> Date: Tue, 2 Jan 2018 21:37:31 +0530 Subject: [PATCH 1/4] Update --- snippets/postfixToInfix.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/snippets/postfixToInfix.md b/snippets/postfixToInfix.md index 52d1a89bb..6736859e6 100644 --- a/snippets/postfixToInfix.md +++ b/snippets/postfixToInfix.md @@ -4,9 +4,7 @@ ``` js const postfixToInfix = RPN => { let convert = RPN.replace(/\^/g,'**').split(/\s+/g).filter(el => !/\s+/.test(el) && el !== '') - let stack = [] - let result = [] - let precedence = {null : 4 ,'**':3 ,'/' : 2,'*': 2,'+':1,'-':1 } + let [stack,result,precedence] = [[],[],{null : 4 ,'**':3 ,'/' : 2,'*': 2,'+':1,'-':1 }] convert.forEach(symbol => { let stra,strb if(!isNaN(parseFloat(symbol)) && isFinite(symbol)){ From 181ace26e20d96ca09af27feeefe123508b765cd Mon Sep 17 00:00:00 2001 From: Rohit Tanwar <31792358+kriadmin@users.noreply.github.com> Date: Tue, 2 Jan 2018 21:53:59 +0530 Subject: [PATCH 2/4] Update infixToPostFix.md --- snippets/infixToPostFix.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/snippets/infixToPostFix.md b/snippets/infixToPostFix.md index 84371ddbc..61ed9f205 100644 --- a/snippets/infixToPostFix.md +++ b/snippets/infixToPostFix.md @@ -1,7 +1,6 @@ ### infixToPostfix -Works perfectly! - +(WARNING)! :- Does not handles `unary` operator ```js const infixToPostfix = expr => { let rpn = '' From 3a285b337531c06d1505450d176547776ab14546 Mon Sep 17 00:00:00 2001 From: Rohit Tanwar <31792358+kriadmin@users.noreply.github.com> Date: Tue, 2 Jan 2018 21:54:39 +0530 Subject: [PATCH 3/4] Update postfixToInfix.md --- snippets/postfixToInfix.md | 1 + 1 file changed, 1 insertion(+) diff --git a/snippets/postfixToInfix.md b/snippets/postfixToInfix.md index 6736859e6..7d4328ff9 100644 --- a/snippets/postfixToInfix.md +++ b/snippets/postfixToInfix.md @@ -1,5 +1,6 @@ ### postfixToInfix +(WARNING) :- Does not handles `unary` operator well. ``` js const postfixToInfix = RPN => { From 37b3abd9da2fea9c05dd1ad803dc4606c34490b0 Mon Sep 17 00:00:00 2001 From: Rohit Tanwar <31792358+kriadmin@users.noreply.github.com> Date: Wed, 3 Jan 2018 11:06:38 +0530 Subject: [PATCH 4/4] Update infixToPostFix.md --- snippets/infixToPostFix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/infixToPostFix.md b/snippets/infixToPostFix.md index 61ed9f205..9a04892ee 100644 --- a/snippets/infixToPostFix.md +++ b/snippets/infixToPostFix.md @@ -4,7 +4,7 @@ ```js const infixToPostfix = expr => { let rpn = '' - let solve = expr.replace(/\^/g,'**').match(/([0-9]+|[\+\(\)\/\-]|\*+)/g).filter(el => !/\s+/.test(el) && el !== '') + let solve = expr.replace(/\^/g,'**')str.replace(/([^\d])\.(\d+)/g, '$10.$2').match(/((\d\.?)+|[\+\(\)\/\-]|\*+)/g).filter(el => !/\s+/.test(el) && el !== '') let stack = [] let precedence = {'**':5,'/':4,'*':4,'+':3,'-':3} solve.forEach(symbol => {