Not all Red-Black Trees are Okasaki (Was: Request for comments, Novacore the sequel to ISO modules)

Liste des GroupesRevenir à l prolog 
Sujet : Not all Red-Black Trees are Okasaki (Was: Request for comments, Novacore the sequel to ISO modules)
De : janburse (at) *nospam* fastmail.fm (Mild Shock)
Groupes : comp.lang.prolog
Date : 07. Nov 2024, 00:59:04
Autres entêtes
Message-ID : <vggvs7$j3jh$1@solani.org>
References : 1 2
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.19
Ok, it seems that SWI-Prolog implements
something else than Okasaki Red-Black Trees.
I tried to find worst cases:
/* Okasaki Red-Black Trees */
?- between(16,32,N), fuzzer(N,D), write(N-D),
     write(' '), flush_output, fail; nl.
16-6 17-6 18-6 19-6 20-6 21-6 22-7 23-7 24-7 25-7
26-7 27-7 28-7 29-7 30-7 31-8 32-8
/* SWI-Prolog Red-Black Trees */
?- between(16,32,N), fuzzer(N,D), write(N-D),
    write(' '), flush_output, fail; nl.
16-6 17-6 18-6 19-6 20-6 21-6 22-6 23-6 24-6 25-6
26-6 27-7 28-7 29-7 30-7 31-7 32-7
In the above the pairs indicate number of nodes
and worst depth of tree. SWI-Prolog has shorter
trees! For example depth 6 is found up to 26 elements,
whereas Okasaki already gives up after 21 elements.
Mild Shock schrieb:
The new multilingual strings are also an exercise in
Novacore. There were a few issues that needed novel
Prolog solutions, to make a Novacore solution.
 One problem was I didn't want to use library(format)
and format/3 to format multilingual strings when
generating error messages. This addresses more
 the later multilingual strings processing than the
multilingual strings store itself. So how resolve this
paradox? Here is my take, a mini format/3 boostraped
 from the Dogelog Player specific atom_split/3:
 % sys_inter_polate(+Stream, +Atom, +List)
sys_inter_polate(Stream, Template, Args) :-
    atom_split(Template, '~', [Head|Tail]),
    put_atom(Stream, Head),
    sys_zipper_output(Args, Tail, Stream).
 % sys_zipper_output(+List, +List, +Stream)
sys_zipper_output([Arg|Args], [Head|Tail], Stream) :-
    writeq(Stream, Arg),
    put_atom(Stream, Head),
    sys_zipper_output(Args, Tail, Stream).
sys_zipper_output([], [], _).
 It only understands format specifier '~', but is sufficient:
 /* German Text */
strings('syntax_error.singleton_var', de, 'Alleinstehende Variable(n) ~, anonyme Variable(n) (_) benutzen.').
 /* English and Fallback Text */
strings('syntax_error.singleton_var', '', 'Singleton variable(s) ~, use anonymous variable(s) (_).').
 LoL
 

Date Sujet#  Auteur
7 Nov 24 o Not all Red-Black Trees are Okasaki (Was: Request for comments, Novacore the sequel to ISO modules)1Mild Shock

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal