logo       

Re: VERY URGENT, CUT AND FINDALL/3: msg#01611

Subject: Re: VERY URGENT, CUT AND FINDALL/3
On Thursday 22 December 2005 21:41, Bart Demoen wrote:
> The fact that findall/3 is perceived as inefficient is more of a
> historic (Prolog) implementation accident than a necessity anyway.

Besides its inefficiency there is also the problem of copying (or not).
Whereever we have mutable terms or attributed variables this is quickly
a more severe problem than simple space/time inefficiency,

Consider list processing as

        findall(Y, (member(X, L), map(X, Y)), Ys)
vs
        maplist(map, L, Ys)

I see many cases where the first is used while the second is intended.
These constructs differ in copying as well as non-determinism handling
of map/2.  Not easy to explain ...

One also commonly finds constructs as this:

        findall(X, Goal, Xs),
        member(X, Xs),
        ...

I think there is a bit of teaching to do on when to use lists as
(answer-)sets and when to use non-determinism.

        Cheers --- Jan




<Prev in Thread] Current Thread [Next in Thread>