Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

ASHes to ASHes, DOS to DOS.


devel / comp.lang.prolog / Re: 50 Years of Prolog Nonsense

SubjectAuthor
o 50 Years of Prolog NonsenseMostowski Collapse

1
Re: 50 Years of Prolog Nonsense

<1634fa1b-bb79-41a2-b3ea-78704adb3bc9n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=9909&group=comp.lang.prolog#9909

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:620a:29cb:b0:699:fee3:265a with SMTP id s11-20020a05620a29cb00b00699fee3265amr4716901qkp.513.1650227953923;
Sun, 17 Apr 2022 13:39:13 -0700 (PDT)
X-Received: by 2002:a5b:dc8:0:b0:624:a898:dea6 with SMTP id
t8-20020a5b0dc8000000b00624a898dea6mr7234950ybr.600.1650227953713; Sun, 17
Apr 2022 13:39:13 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.prolog
Date: Sun, 17 Apr 2022 13:39:13 -0700 (PDT)
In-Reply-To: <24fc2a11-ba45-4e95-8e00-9f9d030a9f2cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.70; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.70
References: <db903ba2-8ccd-418e-bd18-a9eb381cd222n@googlegroups.com>
<f556f96e-c529-4fa7-a2aa-9e64914fa587n@googlegroups.com> <01cd804e-ed22-4bd5-becc-7e40d02355b3n@googlegroups.com>
<c657fedb-baea-4e8f-a0ec-31ef0dd40aadn@googlegroups.com> <e977c06f-7bc4-48b4-be84-819c9deee22bn@googlegroups.com>
<d6891d67-ac96-4ac2-b0a4-05eabd2c9196n@googlegroups.com> <22deb94e-8ea7-4186-b54c-f62acf6bfc21n@googlegroups.com>
<8480178f-c543-4991-8852-7fab3ae36513n@googlegroups.com> <7b455313-f626-4b28-91d3-815c97845f25n@googlegroups.com>
<7358eb33-9ac9-4594-97a4-68b9447459cfn@googlegroups.com> <stttcm$scdj$1@solani.org>
<94f2c74b-f639-43f7-b0a7-3fb19474b8b6n@googlegroups.com> <cffd0ca3-ae91-45c3-941d-357fbb16ea5cn@googlegroups.com>
<93d9c233-ebc8-41f0-bce9-134b89c1c6d1n@googlegroups.com> <cb4d0cda-50b3-4ad7-9af3-240a3582a064n@googlegroups.com>
<1d869c34-e4eb-4e93-898e-0b01f3ffb09dn@googlegroups.com> <cd6b0691-c25c-4867-917b-7d48340b2798n@googlegroups.com>
<fd44ed01-3f23-48ad-9035-ca3a02720ea0n@googlegroups.com> <6751a872-9893-4bb4-9fdf-f7491d1ba826n@googlegroups.com>
<627b1680-c118-4df7-bf0e-f7b1fb885e51n@googlegroups.com> <35a3e608-d22c-4606-9617-25681e7aec08n@googlegroups.com>
<26c9dce5-cd9d-4ee9-a6d1-f02c5ebeb84bn@googlegroups.com> <24fc2a11-ba45-4e95-8e00-9f9d030a9f2cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1634fa1b-bb79-41a2-b3ea-78704adb3bc9n@googlegroups.com>
Subject: Re: 50 Years of Prolog Nonsense
From: burse...@gmail.com (Mostowski Collapse)
Injection-Date: Sun, 17 Apr 2022 20:39:13 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 77
 by: Mostowski Collapse - Sun, 17 Apr 2022 20:39 UTC

Somehow flatten/2 can be used for atom_list_concat/3,
at least this would work, when atoms itself are lists.
But do chars perform better than codes?

I did a little test for Scryer Prolog:

$ target/release/scryer-prolog --version
"v0.9.0-101-gb4486818"
$ target/release/scryer-prolog
....
?- length(L,1000), maplist(=([97, 98, 99, 97, 98, 99, 97, 98, 99]),L),
time((between(1,1000,_), flatten(L,_,[]), fail; true)), fail.
% CPU time: 4.730s
false.

?- length(L,1000), maplist(=("abcabcabc"),L),
time((between(1,1000,_), flatten(L,_,[]), fail; true)), fail.
% CPU time: 4.956s
false.

Using:

flatten([]) --> !, [].
flatten([X|Y]) --> !, flatten(X), flatten(Y).
flatten(X) --> [X].

What is the explanation of the ca. 5% slow-down?

Mostowski Collapse schrieb am Sonntag, 17. April 2022 um 14:10:27 UTC+2:
> Here is a challenge. From SWI-Prolog I am used to:
>
> ?- atomic_list_concat([a,b,c],',',A).
> A = 'a,b,c'.
>
> ?- use_module(library(dialect/ifprolog)).
> true.
>
> ?- atom_split(A, ',', [a,b,c]).
> A = 'a,b,c'.
>
> Something similar available for Scryer Prolog? These predicates
> offer the opportunity for some O(n) implementation, compared
> to a naive Prolog bootstrapping with atom_concat/3 which is O(n^2).
>
> This holds for the modes atom_split(-, +, +) and atomic_list_concat(+, +, -).
> The other mode I am not exactly sure whether there is really an opportunity.
> The predicate mode atom_split(-, +, +) also brings back to Prolog
>
> the join() idiom, widely discussed in JavaScript and Python places.
> Mostowski Collapse schrieb am Sonntag, 17. April 2022 um 02:30:23 UTC+2:
> > Oh my dear, Scryer Prolog lost the battle with its
> > char lists = strings idea and his preference for chars APIs.
> > I don't have a single chars API in Dogelog Player, was
> >
> > fully betting on codes only, makes life much easier.
> > Now this here. BTW: A library charsio does not anymore
> > exist in SICStus Prolog 4.7.1:
> >
> > | :- use_module(library(charsio)).
> > ! Existence error in argument 1 of use_module/1
> > ! file library(charsio) does not exist
> > ! goal: use_module(user:library(charsio))
> >
> > Oh the irony, I did find a library codesio:
> >
> > | ?- use_module(library(codesio)).
> > % loading d:/software/logic/sics/library/codesio.po...
> > % module codesio imported into user
> > % loading d:/software/logic/sics/library/types.po...
> > % module types imported into codesio
> > % loaded d:/software/logic/sics/library/types.po in module types, 0 msec 6432 bytes
> > % loading foreign resource d:/software/logic/sics/library/x86_64-win32-nt-4/codesio.dll in module codesio
> > % loaded d:/software/logic/sics/library/codesio.po in module codesio, 0 msec 64768 bytes
> > yes
> > | ?- read_from_codes("X+Y.", T).
> > T = _A+_B ?
> >
> > LoL


devel / comp.lang.prolog / Re: 50 Years of Prolog Nonsense

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor