I'm trying to work on this Prolog rule you pass in an input of a list of movies and it returns a list of a star that are involved in that particular movie.
Predicate:
starsin(captain_america,chris_evan).
starsin(avengers,chris_evan).
starsin(ant_man,chris_evan).
starsin(captain_marvel,chris_evan).
starsin(iron_man,chris_evan).
starsin(avengers,tom_holland).
starsin(captain_marvel,tom_holland).
starsin(captain_america,tom_holland).
starsin(iron_man,robert).
starsin(avengers,robert).
starsin(captain_america,robert).
I tried to use set of rule but somehow I cant figure out a way to use it recursively:
link([Head],Set) :-
setof(Star1,starsin(Head,Star1),Set).
Input and Output:
link([ironman],Set).
Set=[chris_evan,robert]
Somehow I want to pass in more than one element in the list but I need to use recursive.
Is there anyway I could do it?
linkpredicate give the set of people who are in all of them movies, or do they just need to be in one of them? - Edmund