I'm practicing Prolog by coming up with a very simple database of who has sent and received emails.

I have created a list using findall of the receivers of a pre-specified X.

有帮助吗?

解决方案

to use your list/2:

all_receivers(X,Uniques) :- findall(Y,(email(X,Y)),List),list(List,Uniques).

but the easiest way is sort/2, or better setof/3

all_receivers(X,List) :- setof(Y,X^(email(X,Y)),List).
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top