=-Animals Database -=
animal(mammal,tiger,carnivore,stripes).
animal(mammal,hyena,carnivore,ugly).
animal(mammal,lion,carnivore,mane).
animal(mammal,zebra,herbivore,stripes).
animal(bird,eagle,carnivore,large).
animal(bird,sparrow,scavenger,small).
animal(reptile,snake,carnivore,long).
animal(reptile,lizard,scavenger,small).
animal(mammal,hyena,carnivore,ugly).
animal(mammal,lion,carnivore,mane).
animal(mammal,zebra,herbivore,stripes).
animal(bird,eagle,carnivore,large).
animal(bird,sparrow,scavenger,small).
animal(reptile,snake,carnivore,long).
animal(reptile,lizard,scavenger,small).
1.all the mammals
?- animal(mammal,A,_,_).
2.all the carnivores that are
mammals
?-animal(mammal,A,carnivore,_).
3.all the mammals with stripes
?- animal(mammal,A,_,stripes).
4.whether there is a reptile that has a
mane
?- animal(reptile,_,_,mane).
/* Dating Agency Database */
person(bill,male).
person(george,male).
person(alfred,male).
person(carol,female).
person(margaret,female).
person(jane,female).
couple(X,Y):-person(X,male),person(Y,female). ---->revision
Extend the program with a rule that defines a predicate couple with two
arguments, the first being the name of a man and the second the name of a woman.
Load your revised program into Prolog and test it.
?- couple(X,Y).
Tidak ada komentar:
Posting Komentar