Tutorial by Examples

Predefined operators according to ISO/IEC 13211-1 and 13211-2: PriorityTypeOperator(s)Use1200xfx:- -->1200fx:- ?-Directive, query1100xfy;1050xfy->1000xfy','900fy\+700xfx= \\=Term unification700xfx== \\== @< @=< @> @>=Term comparison700xfx=..700xfxis =:= =\= < > =<...
In Prolog, custom operators can be defined using op/3: op(+Precedence, +Type, :Operator) Declares Operator to be an operator of a Type with a Precedence. Operator can also be a list of names in which case all elements of the list are declared to be identical operators. Precedence is an in...
Two terms may be compared via the standard ordering: variables @< numbers @< atoms @< strings @< structures @< lists Notes: Structures compare alphabetically by functor first, then by arity and lastly by the comparison of each argument. Lists compare by length first, t...
Equality operatorSucceeds ifX = YX can be unified with YX \= YX cannot be unified with YX == YX and Y are identical (i.e. they unify with no variable bindings occurring)X \== YX and Y are not identicalX =:= YX and Y are arithmetically equalX =\= YX and Y are not arithmetically equal

Page 1 of 1