Questions related to the parsing (and possibly the evaluation) of free-form mathematical expressions in strings, lists, or streams
3
votes
1answer
36 views
Evaluating given numbers and operations
The program reads in an operation, and then numbers, and does stuff to them based on that.
Exercise number 1 at this linl
For example, ./this_file sum 1 2 3 would ...
4
votes
1answer
34 views
Safe Reverse Polish Notation
I implemented the following (what I believe to be) safe Reverse Polish Calculator.
Now I'm using foldM to take advantage of the power of Monads. Previously, I was ...
4
votes
2answers
58 views
Evaluating algebra expression using an auxiliary VB class compiled on the fly and consumed in a C# project
I want to create algebra evaluator but I don't want to write my own parser because it takes much time to learn.
I don't like algebra expression in C# because it does not look natural compared to VB ...
3
votes
2answers
48 views
Creating polls and calculator with custom functions and without any global variable
I solved this problem using custom functions and calling them in main function. The challenge was to avoid global variables. Please note that I'm C++ noob and this program is fairly large. I'm ...
1
vote
0answers
18 views
Infix epression evaluation
I'm looking for some feedback on my OCaml implementation of some methods to translate infix expressions to postfix and then evaluate them.
I'm very new to OCaml, coming from C#/Java and JavaScript ...
4
votes
2answers
91 views
Infix to Postfix Converter Program
This is my homework. Kindly help me check it?
The instructions are:
Implement an infix expression to postfix expression converter. You are to implement the infix to postfix algorithm presented ...
6
votes
1answer
77 views
Predictive recursive descent parser for math expressions
I've been learning about language theory and parsing, and decided to write my first parser: a LL(1) recursive descent parser. But actually, it does a little more than just expressions; it can also ...
-2
votes
3answers
72 views
Arithmetic operation from string
I have a string like str = " 4+ 6 * 30";. I have to perform an arithmetic operation on this using C#; My solution to this problem is as follows.
...
6
votes
2answers
187 views
Infix to postfix conversion
I have written a C++ program to convert an infix expression to postfix expression using recursion. I would like to know if it can be improved if possible. Can we improve it by not using a stack? I am ...
4
votes
1answer
85 views
10
votes
2answers
294 views
Four-function expression evaluator
I've been making an interpreter for my own programming language that I've been working on as a hobby. I made an expression evaluator that can evaluate simple mathematical expressions.
It understands ...
3
votes
2answers
117 views
Parsing arithmetic expressions like (x + y * a + b *z)
I have this code which I wrote to parse arithmetic expressions.
However, many people say there are problems with it but don't tell me what the problem is. Please let me know if you see any.
Note ...
5
votes
1answer
59 views
Reverse Polish Notation Calculator
Working through Learn You a Haskell, I made a Reverse Polish Notation calculator.
Please critique it.
...
4
votes
1answer
36 views
Basic Reverse Polish CL Parser
K and R Exercise 5-10
Write the program expr, which evaluates a reverse Polish expression
from the command line, where each operator or operand is a separate
argument.
For example,
...
7
votes
4answers
638 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 ...
3
votes
1answer
399 views
Math Equation as String to Reverse Polish Notation Parser
What I have done is create a console program where users type in a math equation such as 5+4-6 or (5+16(8-4))/16 that follows ...
3
votes
0answers
76 views
Parsing an infix notation expression and converting to reverse polish notation
I'm pretty new to Go, and I do not know the best or idiomatic ways to do most of the stuff, so I'd appreciate feedback on how to make my code better, faster or more idiomatic.
My program is a set of ...
6
votes
2answers
417 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 ...
7
votes
1answer
347 views
Command line reverse polish calculator
Write the program expr, which evaluates a reverse Polish expression from the command line, where each operator or operand is a separate argument.
For ...
4
votes
2answers
382 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
119 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
1answer
133 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.
...
1
vote
3answers
577 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 ...
2
votes
2answers
506 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
527 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
...
3
votes
3answers
856 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 ...
5
votes
4answers
4k views
Reverse polish notation interpreter/calculator
Just for the heck of it, I wrote a simple little interpreter that takes in inputs in the reverse polish notation.
The user will input something like
+ 5 6
...
1
vote
0answers
308 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 ...