PPT Slide
SIMPLE ARITHMETIC and IS
Predicates are only true or false.
We need functions to do arithmetic.
But if a function returns a value, can we assign that value to a variable?
Yes, using the “is” operator.
twice( Y , X ) : - Y is 2 * X .
|?- X is 4 / 2 .
X = 2
|?- X is 5 / 2 .
X = 2.5
|?- twice( 4 , 2 ) .
Yes
|?- twice( Z , 4 ) .
Z = 8
|?- twice( 4 , Z ) .
EXCEPTION
P.22
Previous slide
Next slide
Back to first slide
View graphic version