Previous Up Next

5.15.3  Define an operator: user_operator

user_operator takes as argument:

user_operator returns 1 if the definition is done and else returns 0.

Example 1
Let R be defined on ℝ by x R y= x*y+x+y.
To define the law R, input:

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

Output:

1

Input:

5 R 7

Do not forget to put spaces around R.
Output:

47

Example 2
Let S be defined on ℕ by:
for x and y integers, x S y <=> x and y are not coprime.
To define the law S, input:

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

Output:

1

Input:

5 S 7

Do not forget to put spaces around S.
Output:

0

Input:

8 S 12

Do not forget to put spaces around S.
Output:

1

Previous Up Next