在prolog中创建一个列表

在prolog中创建一个列表,prolog,Prolog,我将如何实现shoppinglist,基于传入的假日,它应该返回该假日各方面所有成分的列表 例如,shoppinglist(万圣节,X)应返回糖、水 /* Facts */ sides(halloween, candy). sides(halloween, soda). ingredient(candy, sugar). ingredient(soda, water). /* Rules */ /* return a list of all ingredients needed for

我将如何实现shoppinglist,基于传入的假日,它应该返回该假日各方面所有成分的列表

例如,shoppinglist(万圣节,X)应返回糖、水

/* Facts */

sides(halloween, candy).
sides(halloween, soda).

ingredient(candy, sugar).
ingredient(soda, water).


/* Rules */
/* return a list of all ingredients needed for holiday */
shoppinglist(Holiday, List) :-

首先对单个成分进行此操作…在序言提示下,在加载事实后,尝试一些手动查询,如
边(holloween)。
然后尝试,
边(holloween,X),成分(X,Component)。
当提示可能的答案时,按