I need to write a function that takes an arithmetic expression and converts it to a string in Reverse Polish notation using Haskell. Creating a function to evaluate an RPN expression is quite easy and need not to worry about, it's only the conversion from arithmetic to RPN that's troubling.
Asked
Active
Viewed 972 times
-2
-
2To parse infix arithmetic you need to implement [operator precedence](http://stackoverflow.com/q/2326328/414413). – Cirdec Apr 09 '15 at 17:04
-
2https://en.wikipedia.org/wiki/Shunting-yard_algorithm – Sneftel Apr 09 '15 at 17:07
1 Answers
1
You could look at parsec for parsing the string. It's powerful and enables you to implement robust parsing. You can then build a data structure out of the input string which you then pass to your RPN logic.

CalumMcCall
- 1,665
- 4
- 24
- 46