Prolog .
. ,
, .
, . , ( ).
. .
. , . , , ; (, , , ); . Prolog .
, . , .
.
, .
, ,
. 5,
,
.
, not
.
.
Condition, Goall, Goal2
Prolog :
Condition,!, % Condition ?
Goall * , Goall,
Goal2 % Goal2
not
, ,
, ,
not Prolog, ,
not ,
, -
.
assert retract
. ,
,
-.
, ,
,
|
|
I. Prolog
.
;
, ,
. ,
.
, , : merge (Listl, List2, List3)
Listl List2 , List3, : merge< [2,4,7], [1,3,4,8], [1,2,3,4,4,7,8])
merge, . merge; Listl, List2, List3):-
Listl " [],!, List3 = List2; %
List2 - [],!, List3 = Listl; % Listl = [X | Restl],
List2 = [Y 1 Rest2),
[ X < Y,!,
Z = X, % Z - List3 merge (Restl, List2, Rest3); Z = Y,
merge; Listl, Rest2, a*st3)L List3 = [Z | Rest3].
, . rae^ge|[|, List, List):-
!. % *
merge! List, [], List). merge! [X j Restl], [Y | Rest2], [X I RestSl):-
X < Y,!, merge (Restl, [Y [ Rest2], Rest3). merge! Listl, [Y | Rest2], [Y | Rest3]):-
merge! Listl, Rest2, Rest3).