swi prolog,匹配数据

时间:2011-09-08 12:01:42

标签: prolog

这是我的源代码,有人可以告诉我什么是错误,而wat是最好的方法,我想展示谁匹配谁...有人可以帮助我吗?

   % Author:
   % Date: 08-Sep-11
   person(may,female,25,blue).
   person(john,male,30,blue).
   match:-person(Fn,'female',Fage,Fatt),
          person(Mn,'male',Mage,Matt),
          Fage<=Mage,
          Fatt=Matt,
           write(Fn ,'-- match with----',Mn).


   error message :55 ?- match.
                        ERROR: Undefined procedure: match/0
                        ERROR:     However, there are definitions for:
                        ERROR:         catch/3
                        false.

1 个答案:

答案 0 :(得分:0)

match :-
    person(Fn,female,Fage,Fatt),
    person(Mn,male,Mage,Matt),
    Fage =< Mage,
    Fatt = Matt,
    format('~w~s~w~n',[Fn ,'-- match with----',Mn]).