The Summary of chapter 4 : "Operator and Arithmetic in Prolog"
1. Operators
There is a another model to write a predicate beside default predicate that we already had been studied before.To binary predicate in which its has 2 argument can be changed as form infix operators.example:
(izzat,nganjuk)
The default predicate like in the top,can be changed to infix operator.
Izzat dari nganjuk
Then for unary predikat's form can be changed as form prefix operator or postfix is operator. Example:
Crazy of reza
that form is changed as prefix operator
reza crazy
or can also be changed as postfix operator
reza was so crazy.
2. Arithmetic
Prolog was provide to do aritmatik's extrapolation utilize kindred notation with Aribase algebra.
Study about aritmatik in prologue is divided as some part. Such as;
Arithmetic operators
a. In this case,there is variable-variable to make program using prolog. This is table below shows of the arithmetic operators and aritmatic fungtions avaible in prolog.
X+Y the sum of X and Y
X-Y the difference of X and Y
X*Y the product of X and Y
X/Y the quotient of X and Y
X//Y the 'integer quotient' of X and Y (the result is truncated to the
nearest integer between it and zero)
X^Y X to the power of Y
-X the negative of X
abs(X) the absolute value of X
sin(X) the sine of X (for X measured in degrees)
cos(X) the cosine of X (for X measured in degrees)
max(X,Y) the larger of X and Y
sqrt(X) the square root of X
b. Operator Precedence in aritmetic Expressions.
Prologue utilizes ordinary algebra algorithms in aritmathic operation.Its exampleA + B*C - D.. In ajabar c and d. is multiplied earlier then added by a. then lessened with D. AT prologue also such. exept, we stay to utilize bracket. Example: (A. + B)* (C + D.).
c. Relational Operators
Operator as =, !=, >,>=, <, =<, can be utilized at Prologue. Utilized to compare two variables.
3. Equality Operators.
This is list of Equality Operators that it used in prolog of each operator.
Arithmetic Expression Equality =:=
a.Arithmetic Expression Inequality =\=
b.Terms Identical ==
c.Terms Not Identical \==
dTerms Identical With Unification =
e Non-Unification Between Two Terms \=
4. Logical operators.
This section gives a brief description of two operators that take arguments that are
call terms, i.e. terms that can be regarded as goals.
a. The not operator
The prefix operator not can be placed before any goal to give its negation. Thenegated goal succeeds if the original goal fails and fails if the original goal succeeds. This is example of example of The not operator.
?- not dog(fido).
no
?- dog(fred).
no
?- not dog(fred).
yes
?- X=0,X is 0.
X = 0
?- X=0,not X is 0.
no
b. The disjunction Operator
The disjunction Operator is use to represent “or”.example:
?- 6<3;7 is 5+2.
yes
Operators and Artithmetic 67
?- 6*6=:=36;10=8+3.
yes
0 comments:
Post a Comment