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
2
votes
1 answer

prefix to infix in C

#include #include #include struct Node{ char* data; struct Node* next; }; typedef struct Node NODE; NODE* push(NODE* top, char* item){ NODE* newNode; newNode=(NODE*)malloc(sizeof(NODE)); …
2
votes
1 answer

R calling infix function with more than 2 parameters

I liked so much index search of xts that I created one for data.frame. "%d%"=function(df1,dt,col='dt_pregao') { if(regexpr('/',dt)>0){ dt=strsplit(dt,'/')[[1]] return(df1[df1[,col] %>=<% c(dt[1],dt[2]),])} return(df1[df1[,col]==dt,])} …
xm1
  • 1,663
  • 1
  • 17
  • 28
2
votes
2 answers

Converting infix notation expression to postfix notation

I'm doing an assignment for my Data Structures course where I have to convert an infix expression to a postfix expression. I'm almost done with it but I keep getting an error when I try entering something like a+b+c It can handle a+b and a+b*c just…
d2jxp
  • 131
  • 4
  • 10
2
votes
0 answers

This python 3 infix notation fails, and I can't see why

I was trying to code some category theory. One requirement is associativity, so "(ab)c = a(bc)" Trying to code that with the infix module, I found my version of the right-hand side ("a(bc)") did not run right. Could anyone suggest what I am doing…
2
votes
1 answer

Prefix to Infix Conversion Algorithm with figure

After some google search I find it! Prefix to Infix This algorithm is a non-tail recursive method. The reversed input string is completely pushed into a stack. prefixToInfix(stack) 1) IF stack is not empty a. Temp -->pop the stack b.…
Tony
  • 1,177
  • 6
  • 18
  • 31
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

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

Meaning of "!!" in Haskell

elementAt :: [a] -> Int -> a elementAt list i = list !! (i-1) This Function return the i'th element of a list. For Example elementAt "haskell" 5 return 'e' can anyone explain me whats the meaning of "!!" , i cant find it anywhere .
Gallaoui
  • 501
  • 4
  • 19
2
votes
1 answer

How to print an infix from a binary expression tree with necessary parentheses?

I'm working on printing an infix expression from my binary tree. However I can display the form in fully parenthesized form but the question is asking to only print the necessary parentheses. For example, consider the expression 7 2 8 - - 9 3 * +.…
user7103094
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
2 answers

Why do just two elements in a list cease to be recognized after I wrap my code in a package?

I'm getting my feet wet with defpackage in Lisp and got off to an ignominious start, namely a bug I can't begin to understand. The code below is an attempt to create a sublanguage to perform infix operations on vectors. I'd like to use this for a…
Paulo Mendes
  • 697
  • 5
  • 16
2
votes
1 answer

Scala infix notation

Here is my code... val strings: Enumerator[String] = Enumerator("1","2","3","4") //create am Enumeratee using the map method on Enumeratee val toInt: Enumeratee[String,Int] = Enumeratee.map[String]{ (s: String) => s.toInt } val toSelf:…
Michael Lafayette
  • 2,972
  • 3
  • 20
  • 54
2
votes
3 answers

converting Infix to prefix conversion

Recently I have went through some sites, for converting the Infix to Prefix notation and finally got tucked up. I have given the steps which I have done.. Ex:- (1+(2*3)) + (5*6) + (7/8) Method 1:- (Manual Conversion without any algorithm):- Step1:…
NANDAKUMAR THANGAVELU
  • 611
  • 3
  • 15
  • 34
2
votes
1 answer

Postfix to infix with unary/binary operators

I am trying to make a converter from postfix to infix notation and need some help. There is already a question about infix-to-postfix conversion, which gives an example I am failing to convert back. (Note: a minus sign is missing there!) The…
Andrei
  • 10,918
  • 12
  • 76
  • 110
2
votes
1 answer

Converting language type to string in R using infix notation

Let's say that I have the following expression in R: someExpr <- substitute(a+2*b) Now I want to look at a subexpression of this, let's say 2*b and generate the string "2*b". I access the subexpression with: someExpr[[3]] 2 * b And the type is…
Gumeo
  • 891
  • 1
  • 13
  • 26