| Deutsch English Français Italiano |
|
<100ujp0$afh8$1@solani.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Mild Shock <janburse@fastmail.fm> Newsgroups: comp.lang.prolog Subject: My stupid Dogelog Player falls back to _<number> (Was: variable ordering guarantees in term_singletons/2) Date: Sun, 25 May 2025 10:18:43 +0200 Message-ID: <100ujp0$afh8$1@solani.org> References: <virv4c$eoih$1@solani.org> <virvig$raf2$1@solani.org> <vis014$raku$1@solani.org> <vis06a$rapp$1@solani.org> <100uhte$8rfn$1@solani.org> <100uigj$aeol$1@solani.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sun, 25 May 2025 08:18:40 -0000 (UTC) Injection-Info: solani.org; logging-data="343592"; mail-complaints-to="abuse@news.solani.org" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0 SeaMonkey/2.53.20 Cancel-Lock: sha1:TPAMtCtEz/3r/IDFewqp4eV8jvI= In-Reply-To: <100uigj$aeol$1@solani.org> X-User-ID: eJwFwYkBwCAIA8CVlCfRcYSS/UfoXTo2moFEpFJqYanLfab7GOLbVqTgN7QtA4ZkP82pVn2+7FZqjGce+QNyRBY1 Bytes: 3696 Lines: 85 SWI-Prolog has quite an elaborate '_' determiner: /* SWI-Prolog */ ?- length(L,2), (R = L; length(R,2)). L = R, R = [_, _] ; L = [_, _], R = [_, _]. ?- length(L,2), (R = f(L); length(R,2)). L = [_A, _B], R = f([_A, _B]) ; L = [_, _], R = [_, _]. Especially the L = R detection, seems challenging. Thats something more complex than my listing/[0,1] and term_singletons/2 usage there. I have no pure Prolog solutions yet. My stupid Dogelog Player falls back to _: /* Dogelog Player */ ?- length(L,2), (R = L; length(R,2)). L = [_309342, _309344], R = [_309342, _309344]; L = [_309342, _309344], R = [_309495, _309497]. ?- length(L,2), (R = f(L); length(R,2)). L = [_310399, _310401], R = f([_310399, _310401]); L = [_310399, _310401], R = [_310574, _310576]. Mild Shock schrieb: > 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