Sponsored links: Algebra eBooks
 

Help Index

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

The Maxima on-line user's manual

Algebra Calculator

Search:

Infix Calculator

Infix

Function: infix (<op>)

infix("uu",101,102);
"uu"(a,b):=a and b;
true uu false;

Function: infix (<op>, <lbp>, <rbp>)

Function: infix (<op>, <lbp>, <rbp>, <lpos>, <rpos>, <pos>) Declares <op> to be an infix operator. An infix operator is a function of two arguments, with the name of the function written between the arguments. For example, the subtraction operator - is an infix operator.

infix (<op>) declares <op> to be an infix operator with default binding powers (left and right both equal to 180) and parts of speech (left and right both equal to any).

infix (<op>, <lbp>, <rbp>) declares <op> to be an infix operator with stated left and right binding powers and default parts of speech (left and right both equal to any).

infix (<op>, <lbp>, <rbp>, <lpos>, <rpos>, <pos>) declares <op> to be an infix operator with stated left and right binding powers and parts of speech <lpos>, <rpos>, and <pos> for the left operand, the right operand, and the operator result, respectively.

"Part of speech", in reference to operator declarations, means expression type. Three types are recognized: expr, clause, and any, indicating an algebraic expression, a Boolean expression, or any kind of expression, respectively. Maxima can detect some syntax errors by comparing the declared part of speech to an actual expression.

The precedence of <op> with respect to other operators derives from the left and right binding powers of the operators in question. If the left and right binding powers of <op> are both greater the left and right binding powers of some other operator, then <op> takes precedence over the other operator. If the binding powers are not both greater or less, some more complicated relation holds.

The associativity of <op> depends on its binding powers. Greater left binding power (<lbp>) implies an instance of <op> is evaluated before other operators to its left in an expression, while greater right binding power (<rbp>) implies an instance of <op> is evaluated before other operators to its right in an expression. Thus greater <lbp> makes <op> right-associative, while greater <rbp> makes <op> left-associative. If <lbp> is equal to <rbp>, <op> is left-associative.

See also Syntax.

Examples:

If the left and right binding powers of <op> are both greater the left and right binding powers of some other operator, then <op> takes precedence over the other operator.

          (%i1) :lisp (get $+ lbp)
          100
          (%i1) :lisp (get $+ rbp)
          100
          (%i1) infix ("##", 101, 101);
          (%o1)                          ##
          (%i2) "##"(a, b) := sconcat("(", a, ",", b, ")");
          (%o2)       (a ## b) := sconcat("(", a, ",", b, ")")
          (%i3) 1 + a ## b + 2;
          (%o3)                       (a,b) + 3
          (%i4) infix ("##", 99, 99);
          (%o4)                          ##
          (%i5) 1 + a ## b + 2;
          (%o5)                       (a+1,b+2)

Greater <lbp> makes <op> right-associative, while greater <rbp> makes <op> left-associative.

          (%i1) infix ("##", 100, 99);
          (%o1)                          ##
          (%i2) "##"(a, b) := sconcat("(", a, ",", b, ")")$
          (%i3) foo ## bar ## baz;
          (%o3)                    (foo,(bar,baz))
          (%i4) infix ("##", 100, 101);
          (%o4)                          ##
          (%i5) foo ## bar ## baz;
          (%o5)                    ((foo,bar),baz)

Maxima can detect some syntax errors by comparing the declared part of speech to an actual expression.

          (%i1) infix ("##", 100, 99, expr, expr, expr);
          (%o1)                          ##
          (%i2) if x ## y then 1 else 0;
          Incorrect syntax: Found algebraic expression where logical expression expected
          if x ## y then
                       ^
          (%i2) infix ("##", 100, 99, expr, expr, clause);
          (%o2)                          ##
          (%i3) if x ## y then 1 else 0;
          (%o3)                if x ## y then 1 else 0

(%o1)                                true
(%i2) 

Infix Example

Related Examples

infix

infix("=>");

"=>"(p,q):=(not p)...

infix("<=>");

Calculate

infix

infix("//");

"//" (r1,r2) := 1/(1/...

r47//r31;

Calculate

infix

infix("=>");

"=>"(p,q):=(not p)...

infix("<=>");

Calculate

infix-lambda-lreduce-map

infix("|");

"|"(p,[x]):=P(p)*lred...

Calculate

infix

"xor"(r,s):= (r and n...

infix("xor");

f:(x xor y xor z) or ...

Calculate

infix

infix("&");

Calculate

infix-is

infix("##",100,101);

"##"(a,b):=is(a<b);

3##4;

Calculate

infix-true

"xor"(r,s):= (r and n...

infix("xor");

f:(z xor y) and (z xo...

Calculate

infix-is

infix("##",100,101);

"##"(a,b):=is(a<b);

3##4;

Calculate

infix

infix("&");

Calculate