Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setof in prolog

what is the source code of setof in prolog?

like image 926
sachin agarwalla Avatar asked Apr 16 '11 03:04

sachin agarwalla


1 Answers

?- listing(setof).
:- meta_predicate setof(?,0,-).

setof(A, B, F) :-
    free_variable_set(A, B, D, C),
    (   C==v
    ->  findall(A, D, E),
        E\==[],
        sort(E, F)
    ;   findall(C-A, D, E),
        (   ground(E)
        ->  sort(E, G),
        pick(G, C, F)
        ;   bind_bagof_keys(E, _),
        sort(E, G),
        pick(G, C, H),
        sort(H, F)
        )
    ).

true.
like image 102
ДМИТРИЙ МАЛИКОВ Avatar answered Sep 27 '22 17:09

ДМИТРИЙ МАЛИКОВ