Re: How to get a set response interactively
"Richard A. O'Keefe" <[email protected]> Thu, 10 Apr 2014 11:24:12 +1200
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On 9/04/2014, at 1:16 PM, Ross Boylan wrote:
> I tried
> ?- setof(OS, mount(_, path([OS | _]), _W), Mounts).
Right there I see an obvious problem: you have a wild-card
in the generator. More than one, in fact.
If you have a 'don't-care' variable in a generator,
you MUST explicitly existentially quantify it. And
this requires having at least two occurrences of the
variable: where it's needed and also in the quantifier.
This has absolutely nothing to do with interactive use
of setof/3. What you need to write is
?- setof(OS, U^V^W^mount(U, path([OS|V]), W), Mounts).
Better still, create an auxiliary predicate:
mount_os(OS) :-
mount(_, path([OS|_]), _).
and then call
?- setof(OS, mount_os(OS), Mounts).
Jan, SWI Prolog has made so many changes lately to make life
easier for some programmers; is there any chance of making it
complain loudly about single-occurrence variables in setof/3
or bagof/3 generators?