change_arg/3 = nb_linkarg/3 ? (Was: PIPs from the Basilisk Chamber)

Liste des GroupesRevenir à cl prolog 
Sujet : change_arg/3 = nb_linkarg/3 ? (Was: PIPs from the Basilisk Chamber)
De : janburse (at) *nospam* fastmail.fm (Mild Shock)
Groupes : comp.lang.prolog
Date : 08. Nov 2024, 18:37:54
Autres entêtes
Message-ID : <vgli9h$lhqn$1@solani.org>
References : 1 2 3 4 5 6 7 8 9 10 11
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.19
I came up with a findall/3 for SWI-Prolog that
doesn’t use call_cleanup/2. The findall2/3 realization
uses nb_linkarg/3 and duplicate_term/2.
findall2(Template, Goal, List) :-
    sys_find2_init(State),
    (Goal, sys_find2_next(Template, State), fail; true),
    sys_find2_fini(State, List).
sys_find2_init(X) :-
    X = v(_,_),
    C = [-|_],
    nb_linkarg(1, X, C),
    nb_linkarg(2, X, C).
sys_find2_next(T, X) :-
    C = [_|_],
    duplicate_term(T, H),
    nb_linkarg(1, C, H),
    arg(1, X, J),              %%% known end cell
    nb_linkarg(2, J, C),
    nb_linkarg(1, X, C).
sys_find2_fini(v(C,D), L) :-
    nb_linkarg(2, C, []),
    arg(2, D, L).
Its not as fast as the bundled findall/3.

Date Sujet#  Auteur
29 Sep 24 * PIPs from the Basilisk Chamber (Was: 50 Years of Prolog Nonsense)7Mild Shock
8 Nov 24 +* Prolog Pearls I: Barklund and Millroth (Was: PIPs from the Basilisk Chamber)4Mild Shock
8 Nov 24 i`* Prolog Pearls II: Barklund and Millroth (Was: PIPs from the Basilisk Chamber)3Mild Shock
8 Nov 24 i `* change_arg/3 = nb_linkarg/3 ? (Was: PIPs from the Basilisk Chamber)2Mild Shock
8 Nov 24 i  `- Re: change_arg/3 = nb_linkarg/3 ? (Was: PIPs from the Basilisk Chamber)1Mild Shock
9 Nov 24 `* Re: PIPs from the Basilisk Chamber (Was: 50 Years of Prolog Nonsense)2Mild Shock
9 Nov 24  `- Re: PIPs from the Basilisk Chamber (Was: 50 Years of Prolog Nonsense)1Mild Shock

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal