15.3. :
?- value! ross, relative_size, Value).
, .
15.4. , .
si 2
:
sl(instance of, square).
sl(side, 5).
r2[ instance_of, rectangle).
r2(length, 6).
r2f width, 4).
square a kind of, rectangle!.
square length, execute! value[Obj,side,L), Ob j, L)).
square(width, execute(value(Obj,side,), Obj, W)),
rectangle) area, execute! area(Obj,A), Obj, A)).
areat Obj, A): -
value(Obj, length, L), value! Obj, width, W),
A is L*W.
, ,
:
?- value{ r2, length, ), value! si, length, ), value< si, area, ).
354 II. Prolog
, ,
: ,
.
: . , ,
,
.
,
, ,
,
, .
, , : .
- , "" " ". .
. , .
, , . , , - .
|
|
, , .. , ,
Prolog , , , , , .
:
;
, , ;
( "if-then"), ;
, ;
15.
, ;
, ;
, ;
;
;
.