variable ordering guarantees in term_singletons/2 (Was: Prolog Development à la Sigmund Freud)

Liste des GroupesRevenir à cl prolog 
Sujet : variable ordering guarantees in term_singletons/2 (Was: Prolog Development à la Sigmund Freud)
De : janburse (at) *nospam* fastmail.fm (Mild Shock)
Groupes : comp.lang.prolog
Date : 25. May 2025, 08:57:10
Autres entêtes
Message-ID : <100uigj$aeol$1@solani.org>
References : 1 2 3 4 5
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0 SeaMonkey/2.53.20
Hi,
People from Vienna were always a little strange.
Why not adopt term_singletons/2 its already around
for a while. You can do quite some magic with it.
Example: Determining singletons during listing,
from Dogelog Player library(tester/tools):
% sys_listing_write(+Term, +Stream)
sys_listing_write(C, T) :-
    term_variables(C, V),
    term_singletons(C, A),
    sys_listing_names(V, A, 0, N),
    write_term(T, C, [quoted(true), variable_names(N), format(true)]),
    sys_answer_period(T).
If term_singletons/2 has the same variable ordering
guarantees, i.e. left to right, as in term_variables/2
you can use an algorithm without expensive lookup,
sys_listing_names([], _, _, []).
sys_listing_names([X|L], [Y|R], K, ['_'=X|S]) :- X==Y, !,
    sys_listing_names(L, R, K, S).
sys_listing_names([X|L], A, K, [N=X|R]) :-
    sys_listing_name(K, N),
    J is K+1,
    sys_listing_names(L, A, J, R).
Just run along the two lists , if something is both in
the term_variables/2 and term_singletons/2 list, generate
a '_' name, otherwise generate a synthetic name.
Bye
Mild Shock schrieb:
Hi,
 The development of Trealla Prolog and Scryer Prolog
looks like a random search in a mental ocean.
 It is like Prolog Development à la Sigmund Freud,
you have only to dig deep enough, and a solution
 will pop up. Otherwise blame your mother or other
relatives that raised you for supression.
 LoL
 Bye
 Examples: Still clueless how to detect singletons?
https://github.com/trealla-prolog/trealla/issues/743

Date Sujet#  Auteur
5 Dec 24 * Ulrich Neumerkel is like Ozzy Osbourne7Mild Shock
5 Dec 24 `* Re: Ulrich Neumerkel is like Ozzy Osbourne6Mild Shock
5 Dec 24  `* Re: Ulrich Neumerkel is like Ozzy Osbourne5Mild Shock
5 Dec 24   `* Re: Ulrich Neumerkel is like Ozzy Osbourne4Mild Shock
25 May08:46    `* Prolog Development à la Sigmund Freud (Was: Ulrich Neumerkel is like Ozzy Osbourne)3Mild Shock
25 May08:57     `* variable ordering guarantees in term_singletons/2 (Was: Prolog Development à la Sigmund Freud)2Mild Shock
25 May09:18      `- My stupid Dogelog Player falls back to _<number> (Was: variable ordering guarantees in term_singletons/2)1Mild Shock

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal