I'm using SWI prolog and was wondering how I can use setof in my source code.
I have a file: prolog_example.pl
which has some facts:
stuff(hello,1,2,west).
stuff(goodbye,3,4,west).
stuff(how,5,6,north).
stuff(are,7,8,north).
canMatch(X,Y):-
stuff(X, _, _, XZ),
stuff(Y, _, _, YZ),
X \= Y.
Now I want to get the set of all west and north teams in a different list. So I put:
setof(X-Y, canMatch(X,Y), ListOfMatches).
within my source code. However when I try to compile or run this in SWI-Prolog, I end up getting this error:
ERROR: prolog_example.pl:37:
No permission to modify static procedure `setof/3'
However, if I pose the setof as a query once the file is loaded (and I take out my setof line), I get the correct answer I want. So how do I use setof in my source code?