Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: A simple calculator implemented using the shunting yard algorithm (victorribeiro.com)
1 point by atum47 on June 1, 2024 | hide | past | favorite | 4 comments


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/shuntingYard

Let me know what you think


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.



Oh, thank you. I'll write some rules to fix that. Appreciate the bug report




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: