<< >> Up Title Contents

2.2.1. Precedence

In an expression with more than one operator, we need to know which operator to evaluate first. For example, the arithmetical expression 1 + 2 * 3 is potentially ambiguous. It could be (1 + 2) * 3 (i.e. 9), or 1 + (2 * 3) (i.e. 7). In fact, the convention in mathematics is to the latter: multiplication has precedence over addition. The * operator in Prolog is defined so that it too has precedence over the + operator.


<< >> Up Title Contents