:

.

.

, . , , , , . -, , , . , , , .

1.2. .

_():- (,).

_():- (, ).

_():- (,), ().

_(,):- (,), (,), (), (,).

, (,X):- (,), (,).

__ (S1,S2):- (,1), (, S2), (S1,S2).

, _ __. , , - . .

5.2. ( ) , '' 'b'.

go:- repeat, get0(C), deal_with(C), fail.

deal_with(97):-!, put(98).

deal_with(X):- put(X).

deal_with (?). 97 98 ASCII '' 'b' .

6.2. get , get ?

get(X):- new_get(X), X32.

new_get(X):- repeat, getO(X).

, - get(97) (, ''?), 'b'. get(97), new_get(97). repeat , get0(97) ( ''). . get0 , repeat - . , repeat , get0(97). , , , 'b'. '', , a repeat . . : , , , . , get. get, , , repeat :

get(X):- repeat, get0(Y), 32Y,!, X-Y.

7.10. , .

pythag(X,Y,Z):-intriple(X,Y,Z), Sumsq is * + Y*Y, Sumsq is Z*Z.

intriple(X,Y,Z):- is_integer(Sum), minus(Sum,X,Sum1), minus(Sum1,Y,Z).

minus(Sum,Sum,0).

minus(Sum,Dl,D2):- Sum0, Suml is Sum-1, minus(Suml,Dl,D3), D2 is D3+1.

is_integer(0).

is_integer(N):- is_integer(N1), N is N1 + 1.

intriple X, Y, Z, , . intriple , . , X, Y Z. minus X, Y Z.

9.1. , . , ; , , .

?- op(255,xfx,--).

((P1--P2), (Gl:-G2)):- _(1,S0,S,G1), _(2,S0,S,G2).

_(0,S0,S,G):- nonvar(PO), tag(P0,S0,S,G).

_((Pl,P2),S0,S,G):-!, _(1,S0,S1,G1), _ac(P2,S1,S,G2), (G1, G2,G).

_(P,S0,S,true):- _(),!, (,S,S0).

_(P,S0,S,G):- tag(P,S0,S,G).

tag(P,S0,S,G):- atom(P), G =.. [P,S0,S].

(true,G,G):-!.

(G,true,G):-!.

(G1,G2, (G1,G2)).

_([]):-!.

_([_ |_]).

([|],C,[A|D]):- (,,D).

([], ,).

, , ( ) . , G, . , S, ( ). , , , . - consult, --B .

?- op(251,fx,{).

?- op(250,fx,}).

?- op(255,XFX,>).

((0--Q0), (P:- Q)):- _(P0,S0,S,P), _(Q0, S0,S,Q1), (Q1, Q).

_((NT,Ts),S0,S,P):- !, nonvar(NT), _(s), tag(NT,S0,Sl,P), (Ts, S0,S1).

_ (NT,S0,S,P):- nonvar(NT), tag(NT,SO,S,P).

_((1,2),S0,S,):- _(1,S0,S1,1), _(X2,Sl,S,P2), (1,2,).

_((Xl;X2),S0,S,(P1;P2)):-!, (Xl,S0,S,P1), (2,S0,S,2).

_(,S,S,):-!.

_(!,S,S,!):-!.

_(Ts,SO,S,true):- _(s),!, (Ts, S,S0).

_(,S0,S,P):- tag(X,S0,S,P).

(,S0,S,):- _(X,S0a,S,Pa), (var(S0a), S0a=S,!, S0=S0a, P=Pa; P=(S0=S0a,Pa)).

tag(X,S0,S,P):- X =..[F|A], (,[S0,S],), P =.. [F|AX].

(true,P,P):-!.

(P,true,P):-!.

(P,Q,(P,Q)).

(,):- var(A),!.

((,),):-!, 1(,,R), (,R).

(,).

1(,(,R),R):- VAR(A),!.

1((,),,R):-!, 1(,,R1), 1(,R1,R).

1(A,(A,R),R).

_([]):-!.

_([_|_]).

([|],,[|D]):- (,,D).

([], X, X).

9.2. phrase () :

phrase(C,):- =.. [Pred|Args], (Args,[,[]],Newargs), =.. [Pred|Newargs], call ().

. 3.6.


: 1.026. /Cache: 3 / 0