Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Often statistics are used as a drunken man uses lampposts -- for support rather than illumination.


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

<1e65b2ec-c913-47cc-8f48-c2d75ca8ebffn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:622a:107:b0:2e1:d655:cc4c with SMTP id u7-20020a05622a010700b002e1d655cc4cmr5372861qtw.669.1650228805880;
Sun, 17 Apr 2022 13:53:25 -0700 (PDT)
X-Received: by 2002:a05:690c:39d:b0:2ef:5629:4ec7 with SMTP id
bh29-20020a05690c039d00b002ef56294ec7mr7627500ywb.125.1650228805697; Sun, 17
Apr 2022 13:53:25 -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:53:25 -0700 (PDT)
In-Reply-To: <1634fa1b-bb79-41a2-b3ea-78704adb3bc9n@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>
<1634fa1b-bb79-41a2-b3ea-78704adb3bc9n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1e65b2ec-c913-47cc-8f48-c2d75ca8ebffn@googlegroups.com>
Subject: Re: 50 Years of Prolog Nonsense
From: burse...@gmail.com (Mostowski Collapse)
Injection-Date: Sun, 17 Apr 2022 20:53:25 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 99
 by: Mostowski Collapse - Sun, 17 Apr 2022 20:53 UTC

In SWI-Prolog, there is no difference larger than 1%:

?- set_prolog_flag(double_quotes, codes).
true.

?- length(L,1000), maplist(=("abcabcabc"),L),
time((between(1,1000,_), flatten(L,_,[]), fail; true)), fail.
% 20,002,000 inferences, 1.000 CPU in 1.000 seconds (100% CPU, 20002000 Lips)
false.

?- set_prolog_flag(double_quotes, chars).
true.

?- length(L,1000), maplist(=("abcabcabc"),L),
time((between(1,1000,_), flatten(L,_,[]), fail; true)), fail.
% 20,002,000 inferences, 1.000 CPU in 0.999 seconds (100% CPU, 20002000 Lips)
false.

Although I didn't consult Scryer Prolog GitHub, I have
a suspicion why chars are slower than codes in Scryer
Prolog. But I wonder what the experts say.

Mostowski Collapse schrieb am Sonntag, 17. April 2022 um 22:39:14 UTC+2:
> 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

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor