fund with findall

Ross Boylan <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <1396299780.9858.10.camel@localhost>
Given
foo(1, 2).
foo(3, 2).
foo(1, 10).

funky(Src, Dest, Matches) :-
	findall(x(Src, Dest), foo(Src, Dest), Matches).

Then funky(1, B, M) produces

M = [x(1, 2), x(1, 10)].

I find this slightly disturbing because it means that Dest got bound to
2 separate values, while remaining unbound at the end.

If anyone could help me understand a bit better what's going on, I would
appreciate it.  The behavior is very useful since it works with Src or
Dest is instantiated, but I'm a little surprised it works.

Thanks.
Ross Boylan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.