Questions tagged [infix-notation]

Operators are written infix-style when they are placed between the operands they act on (e.g. 2 + 2).

Operators are written infix-style when they are placed between the operands they act on (e.g. 2 + 2).

There are a few ways to convert infix to postfix, AKA reverse polish notation.

When working with a recursive descent parser one can factor the grammar.

One can also implement the shunting yard algorithm by Edsger Dijkstra which can be refined into precedence climbing.

540 questions
3
votes
1 answer

Convert Content MathML to infix/math notation string in javascript

How do I convert Content MathML (example below), in to an infix or math notation string. For example converting this: compartment
user1027169
  • 2,627
  • 3
  • 27
  • 50
3
votes
3 answers

Shunting-yard algorithm in c++

I need a function that takes an infix string (like "3 + 4 * 9"), and convert it to postfix (like "4 9 * 3 +"). I got it working until you throw in parentheses within parentheses. I've been working on it all day and can't figure out what I'm doing…
user1311736
  • 83
  • 2
  • 2
  • 7
3
votes
1 answer

Postfix to infix converter Objective C

I am trying to make an RPN calculator program and want to have a label which shows the expression you entered. If you enter 3,5,4,+,/ the label would show ((4+5) / 3). I am having trouble implementing this. I am using a mutableArray I call stack…
2
votes
2 answers

Infix equation solver c++ while loop stack

Im creating an infix problem solver and it crashes in the final while loop to finish the last part a of the equations. I call a final while loop in main to solve whats left on the stack and it hangs there and if i pop the last element from the stack…
user1184034
  • 71
  • 3
  • 11
2
votes
4 answers

How to calculate expression in java?

How to calculate user given Expression in java. E:g, if the given exp is 3*4+(5*6) how to calculate this. can anyone help me out.
Jey
  • 383
  • 2
  • 4
  • 6
2
votes
1 answer

Can someone explain this function and how to type it in Haskell (infix, :-:)

infixr 5 :-: data List a = Empty | a :-: (List a) deriving (Show, Read, Eq, Ord) we just wrote a :-: (List a) instead of Cons a (List a). Now, we can write out lists in our list type like so: ghci> 3 :-: 4 :-: 5 :-: Empty (:-:) 3 ((:-:) 4…
SpringArt
  • 25
  • 4
2
votes
2 answers

Non type-variable argument in the constraint error, while using with infix

Unfortunately I have been facing a strange error. It happens while using infix with data constructor. I am new to Haskell. Can any one help me in this regard ? Prelude> data L a = Cons a (L a) | Emp deriving Show Prelude> 10 `Cons` Emp Cons 10…
John
  • 2,633
  • 4
  • 19
  • 34
2
votes
2 answers

Associativity rule in Infix to Postfix expression

My infix to postfix algorithm using stack: static int Prec(char ch) { switch (ch) { case '+': case '-': return 1; case '*': case '/': return 2; case '^': return 3; } return -1; } static String…
nehacharya
  • 925
  • 1
  • 11
  • 31
2
votes
1 answer

Common Lisp Read Macro for "lazy infix or," to destructure keywords

I have a Common Lisp reader macro to parse lazy/delayed declarations of an "or" relation, using infix syntax separated by pipe chacaters ("|") as well as standard list parentheses and keyword literals. Consider the form (:a :b|:c) -- it represents a…
2
votes
1 answer

Infix to Postfix form in Haskell

I'm a beginner in Haskell and i'm kind of lost on what to use to make this program work. What i have to do is get a String like this: "a+(b/c)" and turn it into its postfix form, which would be like this: "abc/+". The…
2
votes
1 answer

infix function: how to avoid parentheses around supplied argument

I have the following infix fun infix fun Boolean.then(lazyValue: () -> T): T? = if (this) lazyValue() else null with following use case (index > 0) then { data[index - 1].id } I want to rewrite it as index > 0 then { data[index - 1].id…
2
votes
1 answer

Python 3 infix operators

I was looking into python infix operators and I found this: Python: defining my own operators? It was asked a very long time ago but I can't find anything more recent. It seems like more of a hack than I'd normally be comfortable doing. Using that…
2
votes
1 answer

Kotlin coding conventions, infix functions, and bitwise operations

The Kotlin coding conventions, in the section Using infix functions, says: Declare a function as infix only when it works on two objects which play a similar role. Good examples: and, to, zip. Bad example: add. Don't declare a method as infix if it…
Ted Hopp
  • 232,168
  • 48
  • 399
  • 521
2
votes
1 answer

I need help to convert from infix to postfix in C

I was practising some data structures problems that I did previously but this time I don't know what is going wrong in my code. I looked over a long time but I did not found the mistake. When I'm printing I'm just getting the first character and it…
2
votes
1 answer

Testing for too many operands on C++ postfix to infix stack

I'm currently trying to test for if there are too many operands but cannot figure out the condition for when a postfix expression has too many operands. Could someone give me any pointers on what to test for? Here is my function so far: void…