Section "arithmetic"

Providing efficient arithmetic is notoriously difficult for a Prolog system. The reason is that the ISO core standard defines arithmetic expressions. Traversing these in Prolog itself is usually not efficient. Nevertheless, this currently the approach for the Dogelog player.

The following arithmetic evaluable functions are provided:

-(A, B): [ISO 9.1.7]
The predicate succeeds in B with the negation of A.
+(A, B, C): [ISO 9.1.7]
The predicate succeeds in C with the sum of A and B.
-(A, B, C): [ISO 9.1.7]
The predicate succeeds in C with A subtracted by B.
*(A, B, C): [ISO 9.1.7]
The predicate succeeds in C with the product of A and B.
/(A, B, C): [ISO 9.1.7]
The predicate succeeds in C with A float divided by B.
//(A, B, C): [ISO 9.1.7]
The predicate succeeds in C with A truncate divided by B.
rem(A, B, C): [ISO 9.1.7]
The predicate succeeds in C with A remainder B.
float(A, B): [ISO 9.17]
The predicate succeeds in B with the approximated A.
^(A, B, C): [TC2 9.3.10]
The predicate succeeds in C with A int power by B.
div(A, B, C): [TC2 9.1.3]
The predicate succeeds in C with A floor divided by B.
mod(A, B, C): [ISO 9.1.7]
The predicate succeeds in C with A modulus B.

The following arithmetic predicates are provided:

X is Y: [ISO 8.6.1]
The predicate succeeds in X with the evaluation of Y.

Kommentare