Re: fund with findall

Feliks Kluzniak <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
This behaviour of findall/3 is intentional.

What would be the expected final instantiations of Src and Dest? 

When one thinks a little about how to implement findall/3 in a Prolog that does not support it directly (hint: use assert/retract and a failure-driven loop), it becomes obvious that it would be quite difficult to give these variables some sensible instantiations, even if one knew what to expect.

Fortunately, as you point out, this property of findall/3 does not cause any problems.  It is genuinely a feature, not a bug. :-)

Hope this helps a little,
— Feliks

On Mar 31, 2014, at 23:03, Ross Boylan <[email protected]> wrote:

> 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
> 
> _______________________________________________
> SWI-Prolog mailing list
> [email protected]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
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.