我对序言很陌生,并且在这种情况下停留了很长时间。
我有这些规则
show_meal(Meals) :- findall(X, chosen_meal(X), Meals).
show_bread(Breads) :- findall(X, chosen_bread(X), Breads).
show_meat(Meats) :- findall(X, chosen_meat(X), Meats).
show_veggie(Veggies) :- findall(X, chosen_veggie(X), Veggies).
show_sauce(Sauces) :- findall(X, chosen_sauce(X), Sauces).
show_topup(TopUps) :- findall(X, chosen_topup(X), TopUps).
show_side(Sides) :- findall(X, chosen_side(X), Sides).
show_order(Meals, Breads, Meats, Veggies, Sauces, TopUps, Sides) :-
show_meal(Meals), show_bread(Breads), show_meat(Meats), show_veggie(Veggies),
show_sauce(Sauces), show_topup(TopUps), show_side(Sides).
我遇到的问题是,如果show_order中的列表中至少有1个为空,例如show_meat(Meats)为空,则序言将无法成功打印并为我提供未定义的过程。
ERROR: Undefined procedure: chosen_meat/1
ERROR: However, there are definitions for:
ERROR: chosen_meal/1
有没有办法克服这种情况?我想知道在这种情况下是否仍然可以打印show_order。谢谢。