Questions related to the parsing (and possibly the evaluation) of free-form mathematical expressions in strings, lists, or streams

learn more… | top users | synonyms

11
votes
3answers
677 views

CC C# calculator

This is my basic C# calculator; I'm sure there is much that can be improved. This design is based on Bjarne Stroustrup's C++ calculator, a purposely be-bugged version of which can be found at his ...
5
votes
2answers
401 views

Evaluating an expression with integers, +, and *, as well as -, /

There is a job interview question, and the source of the question is here. The solution is pretty simple. We just need to split the input string by + and then by *. Then we compute products in a ...
4
votes
1answer
67 views

Evaluating an expression with integers, +, and *, as well as -, / - revision 3

The original question came from this web site. Revision 1 Revision 2 And this is the third revision. I delete spaces and validate an equation before computing. ...
4
votes
2answers
2k views

Numeric expression parser - calculator

In particular, if someone could describe a better way to go from the tokenized list to the Expression tree, it would be super helpful. I would like to get rid of the casting in the parser but am not ...
10
votes
1answer
92 views

Mathematical expressions evaluator with callbacks, the logic

I hesitated quite a bit of time before posting this question since the code to review is more or less a monster (with regards to its size). It is a basic mathematical expressions evaluator, but with ...
10
votes
3answers
1k views

Basic C# calculator (+,-,*,/)

My 'teacher' requested this problem be solved by parsing the input into a tree based on the order of operations. The class Calc variables are specific to his ...
9
votes
1answer
65 views

Mathematical expressions evaluator with callbacks, the architecture

This question goes hand in hand with another question about a mathematical expressions evaluator in C++. The other question is meant to be read first, this one is but a complement to expose the ...
6
votes
2answers
1k views

Basic C# calculator (+,-,*,/) - V2

Original question: Basic C# calculator (+,-,*,/) My 'teacher' requested this problem be solved by parsing the input into a tree based on the order of operations. The class Calc variables are ...
4
votes
1answer
160 views

Simple Calculator - revised

This is my revised code of the Calculator: ...
10
votes
2answers
280 views

+, -, *, /, () expression calculator

In an effort to understand how compilers work, I wrote a simple expression calculator in C#. A CalculatorExpression takes an infix string, converts the infix string ...
8
votes
4answers
2k views

Simple C++ calculator which follows BOMDAS rules

This was my first attempt at making a C++ calculator. The user basically inputs an expression (I'll use \$1+1*(9*(11-1))\$ as an example) and the program searches for and creates a vector for ...
6
votes
2answers
1k views

Cleaning up Reverse Polish Notation evaluator

I was wondering if anyone had some general clean up advice on my code. I believe that more helper functions would be my case but I could be wrong. 30 lines maximum per method is my rule. I can't seem ...
6
votes
4answers
6k views

Polish notation interpreter/calculator

Just for the heck of it, I wrote a simple little interpreter that takes in inputs in the form of Polish Notation. The user will input something like + 5 6 ...
5
votes
1answer
448 views

Reverse Polish Notation Calculator

Working through Learn You a Haskell, I made a Reverse Polish Notation calculator. Please critique it. ...