Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between infix, infixr, infixl

Tags:

sml

I read a book that uses infix, infixr, and infixl in the sample programs. I'm wondering what the differences are. I'm guessing that infixr performs operation from right to left, and vice versa.

like image 385
segfault Avatar asked Apr 11 '10 16:04

segfault


People also ask

What is the difference between infix and postfix expressions?

What is the difference between infix and postfix? In infix form, an operator is written between two operands, whereas In postfix expression, an operator is written before its operands. Why are parentheses not required in postfix and prefix expressions?

What is the difference between infix and prefix expressions in JavaScript?

So let us learn about them:- An infix expression is a single letter, or an operator, proceeded by one infix string and followed by another infix string. A prefix expression is a single letter, or an operator, followed by two prefix strings. Every prefix string longer than a single variable contains an operator, first operand and second operand

What is the difference between infix form and prefix form?

In infix form, an operator is written in between two operands. An expression in the form of A * ( B + C ) / D is in infix form. This expression can be simply decoded as: “Add B and C, then multiply the result by A, and then divide it by D for the final answer.” Prefix: In prefix expression, an operator is written before its operands.

What is the difference between infix notation and prefix notation?

Infix notation is easy to read for humans, whereas prefix or postfix notation is easier to parse for a machine (computers). The big advantage in prefix or postfix notation is that there never arise any questions like operator precedence. For example, consider the infix expression 1 # 2 $ 3.


2 Answers

Yes, the r/l indicates the associativity. Without testing I'd assume that infix has normal left associativity.

like image 153
Svend Avatar answered Nov 01 '22 10:11

Svend


infix defines the operator to be left-associative, infixr defines it to be right-associative. infixl does not exist.

like image 26
sepp2k Avatar answered Nov 01 '22 08:11

sepp2k