November 22, 2020, 2:43pm
For a goal like
my_goal(A,B,C) in module
my_module but with my_goal/3 not exported and wanting to collect just C into a set.
This was the way I originally posted this, which is wrong.
Then Jan W. gave the correct way.
Also see this SO
November 22, 2020, 4:23pm
November 22, 2020, 4:28pm
Is that a better way, a preferred way, or just another way?
The reason I posted it was because I don’t know of an example with all of these requirements:
Use a goal
Use an existential operator (^)
Use more than one existential variable
Use a module qualifier
November 22, 2020, 7:56pm
It is the way. The setof/3 goal argument is of the shape TermWithExistentialVars^Goal. This means the qualifier must be part of Goal. TermWithExistentialVars can be anything. The convention is to use Var1^Var2^Var3^Goal.
@EricGT See also the
^ specifier for
This extension is used to denote the possibly
^ -annotated goal of
setof/3, bagof/3, aggregate/3 and aggregate/4. It is processed similar to‘0’, but leaving the
^ /2 intact.
That’s how the system would know to call
M:setof(A, X^Goal, As) as
setof(A, X^(M:Goal), As) rather than
setof(A, M:(X^Goal), As).