Prolog

Prolog Arithmetic
Because Prolog is a logic language the assignment statement is a logic statement that relates a variable identifier to a computed numeric value using the keyword "is". The arithmetic operators include:

SymbolMeaningExample
+AdditionX is 1 + 2
-SubstractionX is 1 - 2
*MultiplyX is 3 * 2
/Real DivideX is 7.0 / 3
//Integer DivideX is 7 // 3
modModuloX is 75 mod 12

EXAMPLES:

bonus(Number) :- Number is 2 + 3.
?bonus(D). => D = 5.
?bonus(3). => no.
?bonus(5). => yes.

[TOC][Next]

CS1104 Main Page
Last Updated 03/28/2000
© J.A.N. Lee, 2000