op/3

See also: Predefined Operators

op(Priority,Assoc,Op)

Declares the predicate as operator.

Remarks

op/3 allows to declare the new operators Op with given Priority and Associativity.

Priority is the integer from 1 through 1200. The lower number corresponds to higher priority.

Associativity takes one of three forms:

The letters x and y is used to define the argument priority. x determines the argument with priority higher than operator's one. y determines the argument with priority lower or equal than operator's one. For example: the operator '-' declared with associativity yfx. So, the expression a-b-c is equivalent to (a-b)-c, but not to a-(b-c).

The list of predifined operators

op(1200,xfx,":-").     op(700,xfx,"\==").
op(1100,xfy,";").     op(700,xfx,"=..").
op(1000,xfy,",").     op(700,xfx,"<>").
op(900,fy,"not").     op(700,xfx,"><").
op(700,xfx,"=").     op(500,yfx,"+").
op(700,xfx,"\=").     op(500,yfx,"-").
op(700,xfx,"is").     op(400,yfx,"*").
op(700,xfx,"<").     op(400,yfx,"/").
op(700,xfx,"=<").     op(400,yfx,"div").
op(700,xfx,">").     op(300,xfx,"mod").
op(700,xfx,">=").     op(200,fx,"+").
op(700,xfx,"==").     op(200,fx,"-").

Example

% define the operator has
op(200,xfx,"has").
has(human,head).
has(human,leg).
has(dog,tail).
has(dog,head).
man has head
Yes
man has tail
No
Y has head
Y=human
Y=dog
2 Solutions
Yes