The Prolog program lists the facts for department (Name, Employee1, Employee2, ...) about the names of departments and their employees (number of predicate arguments department not defined beforehand). Write singleJobHolder (List) predicate for finding a list of employees who work only in one department.
Domains
singleJobHolder_list=symbol*
NameEmployees_list=symbol*
Predicates
department_list(Name, Employees).
singleJobHolder_list(List).
Clauses
department( management, knut_billkvist, rune_viking, ahmed_hassan ).
department( administration, lisa_larsson ).
department( economy, judi_larson ).
department( staff, jenny_bengtsson ).
print(N):- findall (X,department(_,_,X),L),
show(L,N).
show([],[],_).
show([H|T],[_|Z],N):-H=N,show(T,Z,N).
show([H|T],[X|Z],N):-H<=N,department(Y,X,H),write(Y," - " ,X),nl,show(T,Z,N)
Goal
print(N).
Comments
Post a Comment