0

我有以下规则:

/*The structure of a subject teaching team takes the form: 
  team(Subject, Leader, Non_management_staff, Deputy). 
 Non_management_staff is a (possibly empty) list of teacher 
structures and excludes the teacher structures for Leader and 
Deputy. 
teacher structures take the form:  
 teacher(Surname, Initial,  
       profile(Years_teaching,Second_subject,Club_supervision)). 
   Assume that each teacher has his or her team's Subject as their  
 main subject.*/  

team(computer_science,teacher(may,j,profile(20,ict,model_railways)), 
 [teacher(clarke,j,profile(32,ict,car_maintenance))], 
 teacher(hamm,p,profile(11,ict,science_club))).

team(maths,teacher(vorderly,c,profile(25,computer_science,chess)), 
 [teacher(o_connell,d,profile(10,music,orchestra)), 
  teacher(brankin,p,profile(20,home_economics,cookery_club))], 
 teacher(lynas,d,profile(10,pe,football))). 

team(english,teacher(brewster,f,profile(30,french,french_society)), 
 [ ], 
 teacher(flaxman,j,profile(35,drama,debating_society))). 

 team(art,teacher(lawless,m,profile(20,english,film_club)), 
 [teacher(walker,k,profile(25,english,debating_society)), 
  teacher(brankin,i,profile(20,home_economics,writing)), 
  teacher(boyson,r,profile(30,english,writing))],
  teacher(carthy,m,profile(20,music,orchestra))).

我应该带回一个团队中任何领导者的首字母和姓氏,该团队总共包含 2 位或更多位以 ICT 作为第二学科的教师。

我是 prolog 的新手,所以对此不确定。另外,我已经正确地返回了结果,但它被返回了 3 次。

对此的任何帮助将不胜感激。

另外,如果这非常容易,我深表歉意。

4

1 回答 1

0

您没有提供用于查找这些教师的代码,所以我不能肯定地说,但如果有一个团队有 3 名成员,他们的第二个科目是 ICT(例如,computer_science),那么会有找到 2 的 3 种方法(AB、AC 和 BC),这将解释您的多个结果。但是说如何修改你的代码来解决这个问题需要看到要修复的代码。

于 2012-05-16T02:27:07.247 回答