views:

108

answers:

2

I have a large number of facts within my program, listing developers and designers in a company, as well as previous projects, like so..

% project(Project Name,Year)
project(efnet, 2007).
% designer(Project Name, Name, Role)
designer(efnet, jane_cole, lead).
% developer(Project Name, Name, Role)
developer(efnet, alex_tobbs, architect).

I have also build a definition that displays a list of either designers or developers working on a project

% employees(Single Project, List of Employees
employees(Project, E)

What I want is to create a new definition that take a list of either designers or developers and displays a list of all the project titles they have BOTH worked on (P); like so..

% projects_of_all(List of Staff, List of Projects)
projects_of_all(S,P):- ...

I can do this easily with findall (or bagof) if I have to find the movies of a single person, but I am not sure how I would do this with a list of the employees. Can someone give me a helping hand with this?

A: 

Try something similar to this, where Es is the list of employees:

setof(P, E^(member(E, Es), employee(P, E)), Projects)

The E^ is an existential quantifier.

starblue
I've just tried it and says "Error: Out of global stack". I should note that in employees Project is a single project.
AlexT