Questions tagged [rpn]

For questions relating to the Reverse Polish Notation, which is a notation for mathematical expressions where the operands precede the operator.

In computing, RPN is ideally suited for a stack-based implementation, and in hardware it has a long history with HP hand-held calculators.

E.g. 1 2 + means apply the + operator to the operands 1 and 2.

198 questions
1
vote
1 answer

How to build 2 lists using only 1 list in Scheme?

I am trying to do a function that takes a list of characters as input, and returns a list that contains all the characters before a specific character given in a condition, so that I can evaluate a postfix expression. Example: the user enters the…
Zok
  • 355
  • 2
  • 15
1
vote
1 answer

Shunting-yard algorithm parsing function agruments

I am trying to get my implementation of the shunting-yard algorithm working. It works well with numbers and operators. But problems arise when I try and add functions to the input. Because the function argument outputs to the left of the function…
user3525516
1
vote
2 answers

Reverse Polish Notation Troubleshooting in C

The question being asked is to evaluate RPN expressions and have the = be the terminating character of the sequence so that the program runs the RPN and calculates the expression it is given. So what I'm having some trouble with is understanding how…
Senglish
  • 115
  • 1
  • 3
  • 9
1
vote
1 answer

How to use AND/OR in a conditional reverse polish notation formula?

Assume I have a condition in the form of "(a > b) OR (c < d)". How can I convert it to reverse polish notation and calculate it? I gave it a try by setting the "and/or" tokens at the lowest precedence level and got "a b c OR > d <". Is it…
1
vote
0 answers

Operators ins "Conversion from Inx to RPN (postfix)" Java. NO STACK, ONLY STRING MANIPULATION

I have used a subroutine to prioritize between the operators: static int p(char c){ if ((c=='+') || (c=='-')) { return 0; } else if ((c=='/') || (c=='*')) { return 1; } else { return -1; } } I have…
1
vote
2 answers

Haskell RPN calculator from F#

I am new at Haskell, could anyone suggest me how to rewrite folowing program in F# to Haskell so it will be as much as similar as possible. Don't know how to define stack data type in Haskell. Thanks let calc input (stck:Stack) = match…
MatejKr
  • 115
  • 12
1
vote
1 answer

regarding char/int on a stack RPN program that works well

Here in the following website: http://blockofcodes.blogspot.com/2014/08/postfix-evaluation-using-cpp-stack.html If I enter value like 1.62 3.5 + 2.7 * then the return value is not in a decimal value. I changed int to double, but it's still giving…
JohnE
  • 13
  • 6
1
vote
2 answers

Spaces between elements in RPN expression java

I have a method getRPNString(), which returns Reverse Polish Notation string. I want to split this string by spacebars to calculate it. Now I can't understand how to add spacebars in my RNP string right, because it's not working with two digits…
dimads
  • 77
  • 6
1
vote
1 answer

Reverse Polish converter

I am trying to make a reverse Polish printer which can perform the following operation- Inputs: (a+(b*c)) ((a+b)*(z+x)) ((a+t)*((b+(a+c))^(c+d))) Outputs: abc*+ ab+zx+* at+bac++cd+^* This is my code: #include #include char…
Alpa8
  • 470
  • 4
  • 12
1
vote
2 answers

Pattern is not splitting as desired, fails to split by +

I have the following code : Pattern pattern = Pattern.compile("\\d+(?:\\.\\d+)?(\\s\\d+(?:\\.\\d+)?)*\\s*[-\\+\\*/\\$£]"); String input = "4.0 5.0 2.0 / + 7.0 - 11.0 34.0 2.0 / 3.0 / 1.0 * +"; Matcher matcher = pattern.matcher(input); List
user1383163
  • 577
  • 1
  • 7
  • 24
1
vote
1 answer

Reverse Polish Notation in C with errors

I need help implementing my code. Here is the code in C. My assignment is to create a program for reverse polish notation. Here is what I have so far. Several Errors I see are "EXE_BAD_ACCESS(code=1, address=0x32)" Any help would be of great use.…
justjoe
  • 11
  • 1
  • 2
1
vote
1 answer

RPN with header, Why doesn't it work?

I did a RPN, but doesn't show the result and the steps, before was appearing, I don't understand what is happening and there are no errors thrown by compiler either. I do always this example: 3.2 1.8 - 10 / 2 + . 4 steps = 2.14 I really don't know…
Susan
  • 25
  • 6
1
vote
1 answer

case without statement and break

I'm dealing with RPN calculator and I've found some approach that's using the switch where some of the case doesn't have any expression and break statement: Here is my approach that's using this algorithm unfortunately it's not working properly As…
advena
  • 83
  • 13
1
vote
1 answer

strtok() function with space delimeter

im trying to implement an RPN calculator using C. The following is the code: float rpn(void) { float ans = 0; int top = -1; float stack[50]; char expression[100]; char *token; float newnumber; float operand1,…
user3126802
  • 419
  • 8
  • 19
1
vote
1 answer

Can't detect 2 digit numbers when converting from RPN to Infix

i am trying to implement a java method which accepts an input in RPN (Reverse Polish Notation) and through use of a stack converts it into an infix notation and calculates it. I have built the stack and a working converter but i am finding problems…
Matthew Cassar
  • 223
  • 2
  • 5
  • 13