Toggle navigation
?
users online
Logout
Open hangout
Open chat for current file
%Ejemplo %Identificación de conjunto de animales empezar:- hypothesis(Animal), write('El animal es: '), write(Animal), nl, undo. %Hipotesis que van a ser puestas a prueba hypothesis(jaguar):- jaguar, !. hypothesis(tigre):- tigre, !. hypothesis(jirafa):- jirafa, !. hypothesis(zebra):- zebra, !. hypothesis(gato):- gato,!. hypothesis("Animal desconocido"). %Identificación de cada hipotesis jaguar:- verify("es mamifero"), verify("es carnivoro"), verify("es color ambar"), verify("tiene manchas oscuras"). tigre :- verify("es mamifero"), verify("es carnivoro"), verify("es color ambar"), verify("tiene rayas negras"). jirafa :- verify("es mamifero"), verify("tiene cuello largo"), verify("tiene manchas oscuras"). zebra :- verify("es mamifero"), verify("tiene rayas negras"). gato :- verify("es mamifero"). /* Crear una pregunta */ ask(Question) :- write('El animal '), write(Question), write('? '), read(Response), nl, ( (Response == yes ; Response == y ; Response == si) -> assert(yes(Question)) ; assert(no(Question)), fail). :- dynamic yes/1,no/1. /* verificacion */ verify(S) :- (yes(S) -> true ; (no(S) -> fail ; ask(S))). /* eliminar las clausulas creadas */ undo :- retract(yes(_)),fail. undo :- retract(no(_)),fail. undo.