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