Canton Software Craftsmanship Message Board › Monthly Mentorship Challenge #2
|Shawn Michael C.||
Prefix expressions Share on LinkedIn
You are given a prefix expression. Write a program to evaluate it.
The first argument will be an input file with one prefix expression per line. e.g.
* + 2 3 4
Your program has to read this and insert it into any data structure you like. Traverse that data structure and evaluate the prefix expression. Each token is delimited by a whitespace. You may assume that the only valid operators appearing in test data are '+','*' and '/'
Print to stdout, the output of the prefix expression, one per line. e.g.
The public shared github repo is here:
Just submit a pull request and we'll merge it into the main branch. As always if you have problems or get stuck please feel free to message me or email me at jaegerpicker at gmail dot com or post your question here or on github. Github is likely the best place that way everyone will see it when looking at the examples.