I have a database containing the following terms:
movie(american_beauty, 1999). director(american_beauty, sam_mendes). actor(american_beauty, kevin_spacey, lester_burnham). actress(american_beauty, annette_bening, carolyn_burnham). actress(american_beauty, thora_birch, jane_burnham). movie(anna, 1987). director(anna, yurek_bogayevicz). actress(anna, sally_kirkland, anna). actor(anna, robert_fields, daniel). actress(anna, paulina_porizkova, krystyna). movie(barton_fink, 1991). director(barton_fink, ethan_coen). director(barton_fink, joel_coen). actor(barton_fink, john_turturro, barton_fink). ...
How to find all actors and actresses who play in one movie only?
How can I iterate through all the database or collect all data with recursion?
I can tell if an actor or actress plays in a given movie with:
plays(Actor,Movie):- actor(Movie,Actor,_). plays(Actor,Movie):- actress(Movie,Actor,_).
I wold like to write a function such as:
and iterate through the actors and actresses, find how many movies do they play
in and print only those who have one movie. How can I do it? Or is it a wrong direction?