Previous Up Next

7.1.2  Defining custom operators

The user_operator command lets you define an operator or delete an operator you previously defined. When you use an operator you defined, you have to make sure that you leave spaces around the operator.

Examples

Let R be defined on ℝ×ℝ by x R y=x y+x+y. To input R:

user_operator("R",(x,y)->x*y+x+y,Binary)
     
1           

(Do not forget to put spaces around R.)

5 R 7
     
47           

Let S be defined on ℕ by “for x and y integers, x S y means that x and y are not coprime.” To input S:

user_operator("S",(x,y)->(gcd(x,y))!=1,Binary)
     
1           

(Do not forget to put spaces around S.)

5 S 7
     
false           
8 S 12
     
true           

Let T be defined on ℝ by T x=x2. To input T:

user_operator("T",x->x^2,Prefix)
     
1           

(Do not forget to put a space before T.)

T 4
     
16           

Let U be defined on ℝ by x U=5x. To input U:

user_operator("U",x->5*x,Postfix)
     
1           

(Do not forget to put a space before T.)

3 U
     
15           

Previous Up Next