我有4个人下订单,我希望他们每个人都吃不同的饮料和不同的甜点。但是uniq的饮料不起作用,我找不到原因?
person(X):- X=steve; X=sam; X=sue; X=sara.
desert(X):- X=fruit; X=pie; X=ice_cream; X=cake.
beverage(X):- X=water; X=coffee, X=milk; X=tea.
uniq(X,Y,Z,W):- dif(X,Y), dif(X,Z), dif(X,W), dif(Y,Z), dif(Y,W), dif(Z,W).
order_all(Person1,D1,B1,Person2,D2,B2,Person3,D3,B3,Person4,D4,B4):-
uniq(Person1,Person2,Person3,Person4) ,
person(Person1),
person(Person2),
person(Person3),
person(Person4),
uniq(D1,D2,D3,D4),
desert(D1),
desert(D2),
desert(D3),
desert(D4).
order_b(B1,B2,B3,B4):-
uniq(B1,B2,B3,B4),
beverage(B1),
beverage(B2),
beverage(B3),
beverage(B4).
答案 0 :(得分:2)
你有一个错字:
beverage(X):- X=water; X=coffee, X=milk; X=tea.
^
Right here
用分号代替冒号。