Questions tagged [polish-notation]

Polish notation, also known as Polish prefix notation or simply prefix notation, is a form of notation for logic, arithmetic, and algebra. Its distinguishing feature is that it places operators to the left of their operands. This tag and [tag:prefix-notation] are really synonyms.

Polish notation, also known as Polish prefix notation or simply prefix notation, is a form of notation for logic, arithmetic, and algebra. Its distinguishing feature is that it places operators to the left of their operands. If the arity of the operators is fixed, the result is a syntax lacking parentheses or other brackets that can still be parsed without ambiguity. The Polish logician Jan Łukasiewicz invented this notation in 1924 in order to simplify sentential logic.

The term Polish notation is sometimes taken (as the opposite of infix notation) to also include Polish postfix notation, or Reverse Polish notation, in which the operator is placed after the operands.

When Polish notation is used as a syntax for mathematical expressions by interpreters of programming languages, it is readily parsed into abstract syntax trees and can, in fact, define a one-to-one representation for the same. Because of this, Lisp (see below) and related programming languages define their entire syntax in terms of prefix notation (and others use postfix notation).

Wikipedia: http://en.wikipedia.org/wiki/Polish_notation

32 questions
1
vote
1 answer

Given a String, What is the Length of the One of the Longest WFF in Polish Notation?

I'm trying to write a version of always popular Count-A-WFF section of the WFF 'N Proof game (no copyright infringement intended) in Python. Alright, not so popular. I think I have everything up and running up as desired for up to the case of a 4…
Doug Spoonwood
  • 236
  • 1
  • 11
0
votes
1 answer

Python program to convert infix to prefix notation

I keep on getting an IndexError: list index out of range, return self.data[-1] # the last element in the list; I think I know what is causing this but I have no clue how to fix it Here is the Stack Class I used: class Stack: # LIFO Stack…
0
votes
1 answer

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. function cuttingString(list) { let adjustArr =…
4156
  • 380
  • 4
  • 17
0
votes
0 answers

Revers expression to Polish Notation in Java

I want to make Reverse Polish Notation algorithm (from simple expression), but my code isn't working. Can anyone explain me why? First of all I split a String expressionto array String[] like this: String[] arraySymbols =…
West Side
  • 166
  • 3
  • 10
0
votes
1 answer

The prefix form of A-B/ (C * D ^ E)?

Could anyone please explain this answer?
0
votes
1 answer

How to configure flexible access rules

BASIC PROBLEM TO SOLVE I am trying to configure flexible rules using user groups and ir.rules in Odoo 10. Basically I want to give users access only to certain records, based on specific values in columns. There are some records that I want to…
philips
  • 437
  • 1
  • 5
  • 15
0
votes
1 answer

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(e*f) Here now what should i do? should…
Bilal
  • 21
  • 2
0
votes
1 answer

Convert Infix to Prefix Notation

I have a task: make a program (C++), which converts "infix" notation to "prefix" and uses own "stack and queue" realizations. But I get: "Critical error detected c0000374" and "Free Heap block modified at ... after it was freed" at last string of…
Uberwaffen
  • 13
  • 2
0
votes
1 answer

Infix to Postfix/Reverse Polish Notation

If I wanted to convert this from infix to postfix: 3 + ( 8 – ( ( 6 – 2 ) ) ) / ( 4 + 5 ) Would this be correct?: 3 8 6 2 - - + 4 5 + / Also, if I wanted to evaluate this: 3 8 6 2 - - 4 5 + / + Would it simplify to this?: 31/9
przm
  • 141
  • 1
  • 2
  • 11
0
votes
0 answers

Creating a Reverse Polish calculator in C++

Assignment: For this assignment, you are to write a program, which will calculate the results of Reverse Polish expressions that are provided by the user. You must handle the following situations (errors): Too many operators (+ - / *) Too many…
TheEWL
  • 19
  • 1
  • 6
0
votes
1 answer

Is there such a thing as an embedded batch language?

I was recently looking through a configuration file for a game I was playing, when it struck me how much the language used in the configuration file resembled a batch language with each line formulated as a command, how simple the syntax was and how…
0
votes
0 answers

RPN calculator program getting an error C

I'm creating a reverse polish notation calculator that can also do a couple of other things using argv[] to enter options. But right now, I just have the RPN calculator option and I'm getting a strange error that I need help on. I am getting the…
0
votes
2 answers

Calculation of Polish Expression

i'm searching for something that explains how i can calculate an Polish Expression, example: if i have this ((1+2)*4)+3, in normal way is 1+2*4+3 = 15, but i need to write this way: 12+4*3+ to using stack getting the value of top and putting in the…
Gabriel Rodrigues
  • 510
  • 1
  • 8
  • 29
0
votes
1 answer

Reverse Polish Notation Code Review

I've been trying to solve this question on SPOJ: http://www.spoj.com/problems/ONP/. I've tried to implement a two Stack solution for the problem stated above. It works fine on my system, but I get a 'Wrong Answer' every time I try to submit the…
AbhyudayaR
  • 51
  • 4
-1
votes
1 answer

Kattis Polish Notation challenge in Python

I'm trying to do the polish notation challenge on kattis.com. Thing is, I feel I have done everything they asked for and I've tried fixing everything I could think of. I even looked up some other's solutions and while theirs are more clean I want to…