Re: findall



On Sun, 17 Feb 2008 07:33:07 -0800, Mark Tarver wrote:

Can findall be efficiently implemented in pure Prolog?

The answer depends on what you consider as pure Prolog - and what you
still consider efficient.

In Prolog with assert and retract, it is possible, actually, that's how
it has been done many times (sometimes with a variant of assert, named
record).

Without assert and retract (or any other magic [*]) the full
semantics of findall is impossible to implement, AFAIK, even if you
give up on efficiency.

[*] e.g. "engines"

You can do something that has the findall flavour in almost pure Prolog
(you need cut or if-then-else) when you just want all different answers,
without their multiplicity.

What is the origin of your question ?

Cheers

Bart Demoen
.



Relevant Pages

  • Convert a "global variable"
    ... I use assert / retract to set a value which should be accessible in the same ... way as a global variable in a functional language. ... I could pass the "global" variable as argument between all predicates of my ...
    (comp.lang.prolog)
  • Re: canonical alternative to assert and retract
    ... is there something like a canonical alternative to assert and retract? ... are there algorithms for translating any Prolog ... to backtracking, it will get very hard to convert the one ...
    (comp.lang.prolog)
  • canonical alternative to assert and retract
    ... is there something like a canonical alternative to assert and retract? ... are there algorithms for translating any Prolog ... more compilers. ...
    (comp.lang.prolog)
  • Re: canonical alternative to assert and retract
    ... is there something like a canonical alternative to assert and retract? ... are there algorithms for translating any Prolog ... I noticed you mentioned Yield Prolog. ...
    (comp.lang.prolog)
  • Re: Networking in Prolog - a survey
    ... I don't think that is a problem, no more than an assert in single- ... If the interpreter starts solving a goal, ... clause or it won't. ... with the retract being the problematic one. ...
    (comp.lang.prolog)