.


:




:

































 

 

 

 


Remember(X, Y, no)




 

remember(X, Y, yes):- assertz(xpositive(X,Y)).

remember(X, Y, no):- assertz(xnegative(X,Y)).

 

clear_facts:-

write("\n\nPlease press the space bar to exit\n"),

Retractall(_, dbasedom), readchar(_).

run:-

animal_is(X),!,

write("\nYour animal may be a (an) ",X),

Nl, nl, clear_facts.

run:-

write("\nUnable to determine what"),

write("your animal is.\n\n"), clear_facts.

 

, . animal_is it_is. , , ositive (X,Y) negative (X,Y). , , :

Does it have hair?

, .

. , :

 

Database

Xpositive(symbol,symbol)

Xnegative(symbol,symbol)

, , :

Xnegative(has,hair).

, , , , :

positive(X,Y):-

xpositive(X,Y),!.

positive(X,Y):- not (xnegative(X,Y)), ask(X,Y,yes).

negative(X,Y):-

xnegative(X,Y),!.

negative(X,Y):- not (xpositive(X,Y)), ask(X,Y,no).

 

³, , positive negative 򳺿 , , .

ask . Y, Yes, , N, - No.

 

ask(X,Y,yes):-!, write(X,"it",Y,'\n'),

Readln(Reply),

frontchar(Reply, 'y',_),

Remember(X,Y,yes).

ask(X,Y,no):-!, write(X,"it",Y,'\n'),

Readln(Reply),

frontchar(Reply, 'n',_),

Remember(X,Y,no).

 

remember(X,Y,yes):- assertr(xpositive(X,Y)).

remember(X,Y,no):- assertr(xnegative(X,Y)).

` . ϳ , , . retractall, clearfacts.

 

clear_facts:-

write("\n\n Please press the space bar to exit\n"),

Retractall(_, dbasedom),





:


: 2015-10-01; !; : 334 |


:

:

- - , .
==> ...

1491 - | 1486 -


© 2015-2024 lektsii.org - -

: 0.011 .