% The structure of a musical group takes the form
% group(Groupname, Director, Players).
% Players is a (possibly empty) list of musician structures,
% but excludes the musician structure for the Director.
% The Director is also a musician in the group.
% musician structures take the form
% musician(Initials,Surname,
% cv(Years_as_professional,Previous_orchestra,Instrument)).
group(classicalstars,
musician(w,mozart,cv(10,vienna_phil,piano)),
[musician(j,haydn,cv(32,vienna_phil,cello)), musician(j,bach,cv(40,dresden_chamber,viola))]).
group(romantics,
musician(l,beethoven,cv(32,vienna_phil,piano)),
[musician(f,liszt,cv(10,vienna_phil,violin))]).
group(nordicsounds,
musician(e,grieg,cv(50,bergen_phil,piano)),
[ ]).
group(impressions,
musician(g,faure,cv(40,paris_chamber,violin)),
[musician(c,saint-saens,cv(51,paris_chamber,violin)), musician(m,ravel,cv(10,paris_chamber,piano)), musician(o,messiaen,cv(5,paris_chamber,violin))]).
director(X):- group(_,X,_).
musicians(X):- group(_,_,Musicians),
member(X,Musicians).
exists(X):- director(X);
musicians(X).
我正在尝试返回恰好有两位非导演小提琴手的乐团的指导者的姓和名。
目前我有以下代码:
hasTwoViolinists(Initial,Surname):- group(_,musician(Initial,Surname,_),[musician(_,_,cv(_,_,violin)),musician(_,_,cv(_,_,violin))]).
这将只返回一个只有两个小提琴手的乐团,这不是我要找的内容。
任何帮助都将不胜感激。