Question

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.

Was it helpful?

Solution

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).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top