22 questions
0
votes
2
answers
75
views
How to use integer methods using `method`, not their infix form, in Ruby
I am looking to programmatically apply a typically infixed operation (eg: +, -, *, /) on two integers, where the operation is specified via a string. I have had success accessing the method itself ...
0
votes
1
answer
136
views
How to extend the postfix(or prefix) notation to support functions with arbitrary parameters?
I need to implement an expression evaluator with some custom types, it is easy to evaluate expressions with only numbers or variables with the help of postfix (or prefix) notation but how to extend ...
1
vote
1
answer
67
views
reversed string not being returned in a c function in program of infix to prefix
Below is the code for infix to prefix conversion. My code works fine until the use of reverse function where it does not print any string after copying. I have tried using a for loop to copy the ...
0
votes
1
answer
645
views
Why popular programming languages like c, c++, java, python, PHP doesn't support postfix (Reverse Polish Notation) or prefix expressions? [closed]
Note:- I'm not talking about Increment & Decrement Operator. I'm talking about prefix & postfix expressions.
Example in python:-
def calculate(a, b, c, d):
return a * ( b + c ) / d
...
0
votes
1
answer
248
views
how to write in reverse direction in c
This is my first question so pardon for non technical language
I am making a program to convert infix to prefix and postfix. I made infix to postfix which is working. Now when I want to infix to ...
0
votes
0
answers
132
views
Prefix/Polish notation for propositional and temporal logic expressions?
I have propositional and temporal logic expressions like:
"phi1 => phi2";
"phi1 U phi2";
"X phi1".
I would like to represent them using prefix notation, i.e, "...
0
votes
1
answer
165
views
Double '+' signs messing with !NaN in JS
Working a evaluator for Polish Notation and I was adding a way to distinguish if the string I got was a number or not using the isNaN function. This works fine, until you add + + to the string.
...
0
votes
2
answers
699
views
Stack And Arithmetic Evaluation
A stack is said to be the ideal data structure for Arithmetic Evaluation. Why is it so?
Why do we even need a data structure for Arithmetic Evaluation? I've been studying about this for some time now ...
0
votes
1
answer
396
views
Evaluating Polish Notation in Java with 2 stacks
I am writing an evaluation code for polish notation. When I overcome ClassCastException I get EmptyStack and when I solve Emptystack I get ClassCast I'm in a loop.
Here is how I wanted to evaluate the ...
1
vote
1
answer
291
views
Match two nested logical AND OR expression tree objects
I need to compare a given logical expression with another in java, to identify if both are the same.
For example, consider an expression as ((a&b)&(c|d)&(e&f)) and other as ((a&e)&...
0
votes
0
answers
245
views
Problem in converting infix expression to a prefix one
Here I am converting an infix expression to a prefix expression.
For some test cases my result is perfect.
But for certain test cases I get an output which is correct according to some sites but ...
0
votes
2
answers
111
views
Is it possible to call the << operator using prefix notation?
I am wondering if I could write, for instance: <<(object, cout); or <<(cout,object); where object is a user defined class which has the << operator overloaded, just as one could ...
5
votes
4
answers
2k
views
Simplification of prefix notation
I am working on a Kattis problem, where I am supposed to take the input in prefix notation, simplify it and return it in prefix notation as well.
These are the examples of inputs and outputs:
Sample ...
-2
votes
1
answer
542
views
Converting from infix to prefix notation in JavaScript
Please help me in JavaScript: The program that I am coding is one that takes in an expression in prefix notation and outputs the same expression in infix notation. The idea behind this program is as ...
0
votes
1
answer
3k
views
Infix to Prefix and Postfix conversion
I'm writing code to convert Infix expression into Postfix and Prefix at the same time.
My problem is I haven't been able to convert into the prefix expression. In my intoprefix() I tried everything, ...
0
votes
1
answer
105
views
Polish Notation Expression (need little help) **/^a-bc+d*ef**
/^a-bc+d*ef
I am little bit confused about this expression
*ef=(e*f)
+d*ef=d+(e*f)
-BC=(b-c)
/^a? if it is ^23= 2^3
here I am confused, what should I do? please need help.
/^a-bc+d*ef
/^a-bc+d(...
3
votes
3
answers
1k
views
Postfix and prefix increment that causes an error
Why does that code does not compile due to an error:
#include <iostream>
using namespace std;
int main()
{
int i = 0;
cout << ++(i++) << " " << i << endl;
...
0
votes
1
answer
2k
views
Infix/postfix/prefix program. Want to print a result using my printResult() function. Need help getting an output
My problem is I don't know how to get anything to output from here. I want to print the postfix result so far using printResult().. how can I do this? I am not sure how to cout the result I am ...
0
votes
0
answers
2k
views
Prefix to Postfix conversion with parentheses
I am really stuck in make conversion of special prefix to postfix operation on our task, let me describe the task similarly :
We have such operation to use as operations in our prefixes, here is the ...
2
votes
2
answers
3k
views
How can I check whether the given expression is an infix expression, postfix expression or prefix expression?
I need algorithms that will check whether given expression is infix, postfix or prefix expression.
I have tried a method by checking first or last 2 terms of the string e.g.
+AB if there is an ...
2
votes
1
answer
295
views
Pseudo code into logical steps?
I am trying to solve the coin-change problem:
Given a list of number , k , how many ways are there to give change to a given amount m.
As one of the resource I have the following pseudo code:
(...
4
votes
4
answers
11k
views
Prefix notation to infix notation in Python
I am writing a small calculator (with prefix notation) and I'm curious how I'd convert prefix notation to infix notation. I currently have a function, but it's being weird, and I'm not sure how to fix ...