Questions tagged [math-expression-eval]

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

Filter by
Sorted by
Tagged with
6
votes
2answers
5k views

Expression parser using the shunting yard algorithm

I am trying to implement an expression parser via the shunting yard algorithm about which I learnt here. I am able to get the correct results for the cases I'm testing, but I think it would be better ...
13
votes
3answers
20k views

Math expression solver

I've recently stumbled upon an interesting challenge for me: You should develop C application, that solves math expressions. Operations such as (+,-,*,/) should be supported, as well as (cos, sin, ...
5
votes
2answers
7k 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 ...
3
votes
1answer
340 views

Refactoring calculator expression

I was doing a simple exercise to calculate the amount based on an expression. For example: (((2*2)+(3*5/5)+(2*5))) outputs 17 ...
2
votes
2answers
46k views

Postfix evaluation using a stack

I just wrote the code to evaluate a postfix expression and would like it if someone reviews it for me, it works perfectly fine but I'm having trouble adding the character "=" at the end. ...
2
votes
1answer
348 views

Advanced Calculator Kata

This is the CalculatorAdvanced Kata from the Kata gem. I've just finished it and would love some feedback on my solution. ...
3
votes
3answers
621 views

Parser for an arithmetic expression

I am a student, and I am doing websites as freelancer. Lately I have started learning design patterns, refactoring, and test-driven development so that I can improve the maintainability, performance, ...
4
votes
2answers
427 views

Evaluating expressions with various mathematical methods

I have started to learn Java and I need your critique for my first program. It is an interpreter that can calculate any expression including abs(), ...
2
votes
1answer
5k views

Infix to Postfix conversion in Java

I have written an infix-to-postfix program that I would like reviewed and with a few suggestions on improving it, such as a more modularized approach. ...
2
votes
3answers
4k views

Calculating postfix notation using two forms of input

My postfix program essentially allows the user two input options to calculate a postfix equation: Confirmations after each input (after an input, the user is ask for another number, operator, or ...
1
vote
1answer
28k views

Calculator application running on a console

I have a calculator created using C# that is running on a console. The calculator accepts a string input (e.g. 5+5) then produces the result (5+5=10). It will then prompt the user to enter another ...
2
votes
2answers
939 views

RPN Evaluator that writes the results to a text file

For homework, I had to write an RPN Evaluator and write the results to a text file. I've done all that, but it feels weird, like the writing to my results text file. It also doesn't feel efficient. ...
2
votes
1answer
2k views

Calculator parsing S-expressions

The following program is supposed to be a (command line) calculator that parses expression following syntax similar to Lisp's S-expressions. Some examples: $ echo "(+ 5 5)" | ./a.out 10....
3
votes
3answers
2k views

RPN-Stack-Based Recursive Calculator Needs Tuneup

This function takes an array of strings and numbers and recursively processes it as a kind of "calculating program". The structure is based on Reverse Polish Notation, so the top object in the stack (...
6
votes
4answers
12k 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 And ...
5
votes
0answers
574 views

Standard Algebraic Derivative Calculator

I had some difficulty with this problem, so I'm sure there is a better way. Here is the question from SICP: Exercise 2.58 Suppose we want to modify the differentiation program so that it ...