Operators


next up previous contents
Next: Symbolic differentiation
Up: Introduction to Prolog for Mathematicians
Previous: The two ways to represent graphs

Operators

In the structure complex(a,b), complex is called the functor. Normally, structures are written in prefix notation, with the functor before its arguments.

Prolog allows us to declare that a given functor can be written between two arguments (infix), after an argument (postfix), or before an argument (prefix). Doing this avoids the need for brackets. Such functors are called operators. Operators can be given different precedences and associativities.

Some functors, such as +, *, is, and \=, are already defined as operators by the system. This is why we can write C is A+B instead of is(C,+(A,B)). However, the bracketed form is also allowed.

Note: These operators are atoms. As well as sequences of letters, atoms can be sequences of ``symbol characters''. Examples: +, ++, -->.



Jocelyn Ireson-Ireson-Paine
Mon Jul 17 22:27:41 BST 1995