Questions tagged [postfix-notation]

Postfix notation (also known as Reverse Polish Notation, RPN) is a mathematical notation wherein every operator follows all of its operands, in contrast to Polish notation, which puts the operator in the prefix position.

Postfix notation (also known as Reverse Polish Notation, RPN) is a mathematical notation wherein every operator follows all of its operands, in contrast to Polish notation, which puts the operator in the prefix position.

Both and postfix notation have the advantage over infix notation that operator precedence is completely defined by the expression, without parentheses being required, which further implies that both can be evaluated linearly by machine instructions without parsing.

572 questions
2
votes
1 answer

haskell reverse polish notation

being new to haskell I decied to try and implement a mini reverse polish notation function: Takes in a list of type int and a string operator ('*','+','/','-') apply the operator to the tail element and the tail-1 element return the resultant list…
2
votes
1 answer

Python prefix postfix infix, no parentheses

I came to Python from Mathematica. Are there prefix, postfix, and infix operators without parentheses like in Mathematica in Python? e.g. In Mathematica Print@@string string~Join~string data//Sum I find I'm constantly using print to test functions…
2
votes
3 answers

What is this unary postfix in dart/flutter?

i saw this unary postfix in Dart/flutter code: ?. like this: videoController?.dispose(); and i want to know how it work...
Meta Code
  • 557
  • 1
  • 7
  • 15
2
votes
1 answer

What Crossover Method should I use for crossing Postfix expressions in Genetic Algorithm?

I'm building a project whose main objective is to find a given number (if possible, otherwise closest possible) using 6 given numbers and main operators (+, -, *, /). Idea is to randomly generate expressions, using the numbers given and the…
2
votes
1 answer

C programming switch statements to find a number or a letter

Hello everyone I was trying the questions from the C programming language book by by Brian W. Kernighan (Author), Dennis M. Ritchie (Author).The book provides the code for a basic reverse Polish Calculator but I do not understand how #define NUMBER…
cv14
  • 77
  • 1
  • 8
2
votes
3 answers

Is it possible to construct a tree of postfix or prefix form?

Let I have some expression as 2*3/(2-1) +5*(4-1) . It is infix notation. Of course I can construct for this expression a tree that you can see on image. enter image description here Then, let's write this expression in postfix and prefix forms.…
neo
  • 1,314
  • 2
  • 14
  • 34
2
votes
2 answers

How do I define a postfix function in Python?

I know that if you create your own object you can define your own methods on that object. my_object_instance.mymethod() I also know you can define infix functions with the infix package. obj1 |func| obj2 What I want is the ability to define a…
Manny
  • 23
  • 2
2
votes
3 answers

Infix to postfix algorithm in python

For my data structures class I have to create a basic graphing calculator using Python 3. The requirement is that we have to use a basic Stack class. The user enters the equation in "infix" form which I'm then supposed to convert to "postfix" for…
aurvandel
  • 23
  • 1
  • 1
  • 6
2
votes
1 answer

Modify the Shunting Yard Algorithm to include a wall operator |

How would the standard Shunting Yard Algorithm be modified to include a 'wall' symbol, |, representing the end of the function parameters? That is, to support a modification of postfix notation (Reverse Polish Notation) which allows functions with…
bitsmcgee77
  • 391
  • 3
  • 10
2
votes
1 answer

Getting wrong outputs in infix to postfix application with java

i recently wrote a java program that takes an infix expression and converts it into a postfix expression. It works for the most part but i am getting wrong outputs for some expressions. For example the expression a+b+c+d+e will output abcde+++++…
Thomas
  • 23
  • 3
2
votes
1 answer

C++ postfix evaluation with decimal points

I've got the shunting yard algorithm implemented (using code from wikipedia, modified to use stl stacks/queues), but now I'm wondering how it's going to evaluate decimals that I get from division. The javascript app at scriptasylum.com (can't link)…
s00pcan
  • 163
  • 1
  • 2
  • 9
2
votes
1 answer

Converting a prefix expression to postfix

I'm trying to implement a program that changes a prefix expression to a postfix one using recursion. I've written what I thought would work but instead of the output ab/c*de+f*- I get aa/aa/*aa/aa/*- instead. I think my code is getting stuck when…
Bell
  • 69
  • 4
  • 12
2
votes
2 answers

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 operator in the very first index of string then its a…
Ahsan
  • 412
  • 5
  • 17
2
votes
1 answer

(Python) How to stop calculation after a ZeroDivisionError

Is there a way to stop everything after an exception? For example, I'm creating a reverse polish notation calculator (to learn postfix) and I want to make sure "Cannot divide by zero" is printed out if there is a "0" in my string. I got it to do…
2
votes
1 answer

RPN short circuit evaluation

I am now in the midst of making a simple bytecode interpreter that uses RPN for expression notation and really postfix notation for anything, but now I've come to the question which is: can short circuit evaluation actually be used on postfix…