Show HN: A simple calculator implemented using the shunting yard algorithm (victorribeiro.com) 1 points by atum47 2y ago ↗ HN
[–] atum47 2y ago ↗ A while back I saw this video (link in the readme) showing the shunting yard algorithm and I decided to implement it in JavaScript.Here's the link to the repository https://github.com/victorqribeiro/shuntingYardLet me know what you think [–] trealira 2y ago ↗ I like how simple it is. Thanks for sharing.By the way, I found one or two bugs.The empty parentheses alone are treated as undefined: > () undefined And I think any equation using empty parentheses as an expression gets treated as NaN: > 5 + () NaN Empty parentheses should probably just be a parse error. [–] atum47 2y ago ↗ Oh, thank you. I'll write some rules to fix that. Appreciate the bug report [–] atum47 2y ago ↗ this is now fixed.https://github.com/victorqribeiro/shuntingYard/pull/1/commit...
[–] trealira 2y ago ↗ I like how simple it is. Thanks for sharing.By the way, I found one or two bugs.The empty parentheses alone are treated as undefined: > () undefined And I think any equation using empty parentheses as an expression gets treated as NaN: > 5 + () NaN Empty parentheses should probably just be a parse error. [–] atum47 2y ago ↗ Oh, thank you. I'll write some rules to fix that. Appreciate the bug report [–] atum47 2y ago ↗ this is now fixed.https://github.com/victorqribeiro/shuntingYard/pull/1/commit...
[–] atum47 2y ago ↗ this is now fixed.https://github.com/victorqribeiro/shuntingYard/pull/1/commit...
4 comments
[ 3.9 ms ] story [ 22.3 ms ] threadHere's the link to the repository https://github.com/victorqribeiro/shuntingYard
Let me know what you think
By the way, I found one or two bugs.
The empty parentheses alone are treated as undefined:
And I think any equation using empty parentheses as an expression gets treated as NaN: Empty parentheses should probably just be a parse error.https://github.com/victorqribeiro/shuntingYard/pull/1/commit...