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
6
votes
4 answers

Any reason I couldn't create a language supporting infix, postfix, and prefix functions, and more?

I've been mulling over creating a language that would be extremely well suited to creation of DSLs, by allowing definitions of functions that are infix, postfix, prefix, or even consist of multiple words. For example, you could define an infix…
sanity
  • 35,347
  • 40
  • 135
  • 226
6
votes
2 answers

How to evaluate Reverse polish notation using stacks

Can this postfix expression can be evaluated? 6 2 3 + - 3 8 2 / + * 2 5 3 +
Zeeshan Asif
  • 61
  • 1
  • 1
  • 3
6
votes
1 answer

Handling extra operators in Shunting-yard

Given an input like this: 3+4+ Algorithm turns it in to 3 4 + + I can find the error when it's time to execute the postfix expression. But, is it possible to spot this during the conversion? (Wikipedia article and internet articles I've read do not…
mikbal
  • 1,168
  • 1
  • 16
  • 27
6
votes
2 answers

Postfix stack calculator

I've created a stack calculator for my Java class to solve equations such as 2 + ( 2 * ( 10 – 4 ) / ( ( 4 * 2 / ( 3 + 4) ) + 2 ) – 9 ) 2 + { 2 * ( 10 – 4 ) / [ { 4 * 2 / ( 3 + 4) } + 2 ] – 9 } We are suppose to implement { } [ ] into our code. I…
user1444775
  • 71
  • 1
  • 1
  • 6
5
votes
1 answer

Is postderef syntax on hashes supported?

Let's say I have my %foo; Can I set keys foo, bar, baz to a b c by taking a slice and doing parallel assignment with postfix notation? %foo->@{qw/foo bar baz/} = qw/a b c/ I used this syntax and I was told it was only "accidentally working". I…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
5
votes
1 answer

Parse expression (with custom functions and operations)

I have a string, which contains a custom expression, I have to parse and evaluate: For example: (FUNCTION_A(5,4,5) UNION FUNCTION_B(3,3)) INTERSECT (FUNCTION_C(5,4,5) UNION FUNCTION_D(3,3)) FUNCTION_X represent functions, which are implemented in…
red
  • 119
  • 2
  • 9
4
votes
3 answers

Can you implement arithmetic operator as variables in C?

I'm trying to program a reverse polish calculator and I didn't wanted to write switches for every single arithmetic operator inputted. Is it possible to input an arithmetic operator and use it as such inside the language itself? For example, the…
minh anh b
  • 51
  • 4
4
votes
0 answers

Could an Applicative Language use Postfix Notation?

I've always found postfix languages like Factor to be far more readable than prefix (Lispy languages) and infix/postfix languages (all C-style languages, if we include both operators and functions). Unlike prefix languages, you don't need for…
Louis
  • 2,442
  • 1
  • 18
  • 15
4
votes
1 answer

AST vs Postfix Algorithm

I am creating a database capable of performing SQL queries. I'm using Flex / Bison to create my AST (abstract syntax tree). For example: select * from table where score> 10 * (age * salary) When i evaluate this AST tree, i traverse the tree,…
p.magalhaes
  • 7,595
  • 10
  • 53
  • 108
4
votes
2 answers

Postfix calculation in smalltalk

I have to write a code to evaluate a postfix notation(reverse Polish evaluation) in Smalltalk. I have gone through the documentation and have also implemented a stack. This is the code I have written so far: Object subclass:…
4
votes
3 answers

Postfix to Infix with minimum number of parentheses

I am looking for algorithm postfix to infix notation which will produce the minimum number of the parentheses. I have found that but it will produce many, many parentheses:…
Yoda
  • 17,363
  • 67
  • 204
  • 344
4
votes
4 answers

Postfix Calculator

Making a console application in C sharp to solve expressions in postfix notation by utilizing a stack, such as: Expression: 43+2* Answer: 14 What I've done so far: using System; using System.Collections; using System.Linq; using…
user1797574
4
votes
2 answers

How does one convert '+' to +, '*' to *, etc

I'm writing a function that reads a postfix expression in the form of a string and computes it accordingly. Is there a simple way to convert the character of an arithmetic operator to the arithmetic operator itself in C++?
Derek W
  • 9,708
  • 5
  • 58
  • 67
4
votes
2 answers

Seg Fault at return statement in function

My program is supposed to convert a prompt from infix to postfix. So far, through a debugger and various other methods, I have located the exact point at which I segfault, but don't understand why. Here's my code: Here's itop.h: using namespace…
3
votes
4 answers

Could a concatenative language use prefix notation?

Concatenative languages have some very intriguing characteristics, such as being able to compose functions of different arity and being able to factor out any section of a function. However, many people dismiss them because of their use of postfix…
1
2
3
38 39