member and findall or setof don't get along?
Ross Boylan <[email protected]> Mon, 14 Apr 2014 23:52:40 -0700
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <1397544760.1612.57.camel@localhost> |
The following fails on the first recursion at the findall:
cd1([Disk | Ds], SoFar, Names, WithDates) :-
format("Ancestor Graph ~p: ", Disk),
deep_ancestors(Disk, now, Graph),
format(atom(FileName), "ancestors-~p.svg", [Disk]),
u_plot(Graph, FileName),
pgraph(Graph, WithDates), nl, nl,
vertices(Graph, Vs),
%setof(Name, W^member(nw(Name, W), Vs), Names),
findall(Name, member(Name, Vs), Names),
append(SoFar, Names, SoFar2),
cd1(Ds, SoFar2, Names, WithDates).
It also failed with the setof. So on the first call it works; then it
recurses and fails. In the debugger it simply fails immediately at the
line, even if I try to step in. But see below for a variant in which it
succeeds only if stepped into with the debugger.
When I try to reproduce with a small example, using the value of Vs
showing in the debugger just before the failure, everything works:
weird(Names) :-
Vs = [ nw(littleboy,now),
nw(pdb,now),
nw(pdb5,now),
nw(dpath([lv(backup,littleboy)]),now),
nw(path([oscorn1, usr, local, var, spool, bacula]),now),
nw(lv(backup,littleboy),now)
],
setof(Name, W^member(nw(Name, W), Vs), Names).
Also, using
setof(Name, cd1a(Vs, Name), Names),
with the helper
cd1a(Vs, Name) :-
member(nw(Name, _), Vs).
fails at the same spot if I step over ('s') setof. But if I trace into
it (' '), the entire operation succeeds. Then the next u_plot fails.
commenting out u_plot and pgraph did not help. Vs is not empty and
consists entirely of nw(_,_) items according to the debugger.
Running 6.4.1.