我在Prolog中有以下列表:
fruit(banana, yellow, curvy, 4).
fruit(apple, green, round, 2).
fruit(kiwifruit, green, round, 7).
fruit(mango, orange, round, 1).
fruit(watermelon, red, round, 8).我想要一个能返回所有绿色水果的查询。我该怎么做呢?我和findall/3 and bagof/3玩了很久,但是我想不通。
发布于 2012-08-24 11:31:23
使用以下查询:
fruit(Fruit, green, Shape, Count).这将返回第二个值为“green”的所有水果/4规则,并返回第一个、第三个和第四个值的值。
https://stackoverflow.com/questions/12102765
复制相似问题