Hi,
Functional requirement:
?- Y = g(_,_), X = f(Y,C,D,Y), term_singletons(X, L),
L == [C,D].
?- Y = g(A,X,B), X = f(Y,C,D), term_singletons(X, L),
L == [A,B,C,D].
Non-Functional requirement:
?- member(N,[5,10,15]), time(singletons(N)), fail; true.
% Zeit 1 ms, GC 0 ms, Lips 4046000, Uhr 11.08.2025 01:36
% Zeit 3 ms, GC 0 ms, Lips 1352000, Uhr 11.08.2025 01:36
% Zeit 3 ms, GC 0 ms, Lips 1355333, Uhr 11.08.2025 01:36
true.
Can your Prolog system do that?
P.S.: Benchmark was:
singletons(N) :-
hydra2(N,Y),
between(1,1000,_), term_singletons(Y,_), fail; true.
hydra2(0, _) :- !.
hydra2(N, s(X,X)) :-
M is N-1,
hydra2(M, X).
Bye
Arrow functions cannot use yield within their body
and cannot be created as generator functions.
?- dict_arrow({foo:123,bar:baz}, _X), call(_X, Y, _).
Y = foo;
Y = bar.
?- dict_arrow({foo:123,bar:baz}, _X), call(_X, foo, Y).
Y = 123;
fail.
Hi,
Here I am not agreeing with John W. Lloyd,
when in his 2nd monograph Logic for Learning,
he proposes basic terms to cover
Logic for Learning
https://users.cecs.anu.edu.au/~jwl/LogicforLearning/
certain if-then-else lambda terms. We can also
do without if-then-else, if we have a complete
key domain and do not model a default.
The translation is as follows:
dict_arrow({D}, (X,Y) => Z) :- dict_arrow(D, X, Y, Z).
dict_arrow(K:V, X, Y, (X = K, Y = V)).
dict_arrow((A,B), X, Y, (C;D)) :-
dict_arrow(A, X, Y, C),
dict_arrow(B, X, Y, D).
They work as expected:
?- dict_arrow({foo:123,bar:baz}, _X), call(_X, foo, Y).
Y = 123;
fail.
?- dict_arrow({foo:123,bar:baz}, _X), call(_X, jack, Y).
fail.
And these dicts even allow something that Mozilla
arrow functions currently cannot do. They can yield,
i.e. act as enumerators. Here an example enumerating keys:
?- dict_arrow({foo:123,bar:baz}, _X), call(_X, Y, _).
Y = foo;
Y = bar.
Bye
Mild Shock schrieb:
Hi,
Functional requirement:
?- Y = g(_,_), X = f(Y,C,D,Y), term_singletons(X, L),
L == [C,D].
?- Y = g(A,X,B), X = f(Y,C,D), term_singletons(X, L),
L == [A,B,C,D].
Non-Functional requirement:
?- member(N,[5,10,15]), time(singletons(N)), fail; true.
% Zeit 1 ms, GC 0 ms, Lips 4046000, Uhr 11.08.2025 01:36
% Zeit 3 ms, GC 0 ms, Lips 1352000, Uhr 11.08.2025 01:36
% Zeit 3 ms, GC 0 ms, Lips 1355333, Uhr 11.08.2025 01:36
true.
Can your Prolog system do that?
P.S.: Benchmark was:
singletons(N) :-
hydra2(N,Y),
between(1,1000,_), term_singletons(Y,_), fail; true.
hydra2(0, _) :- !.
hydra2(N, s(X,X)) :-
M is N-1,
hydra2(M, X).
Bye
Hi,
That Mozilla has no yield in their arrow functions,
is documented here:
Arrow functions cannot use yield within their body
and cannot be created as generator functions.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
So the Dogelog Player arrow functions are the
next step in short function literals. They offer the
beauty of unification and backtracking.
We made the keys example to show backtracking:
?- dict_arrow({foo:123,bar:baz}, _X), call(_X, Y, _).
Y = foo;
Y = bar.
But this example suffers from a spurious choice point:
?- dict_arrow({foo:123,bar:baz}, _X), call(_X, foo, Y).
Y = 123;
fail.
If we put the arrow function for the dict, into a static
clause, Dogelog Player will do an ahead of time compilation
of the arrow functions, and the spurious choice point goes away:
?- [user].
lloyd(((X,Y) => (X = foo, Y = 123; X = bar, Y = baz))).
^Z
?- lloyd(_D), reference(_D).
true.
?- lloyd(_D), call(_D, foo, X).
X = 123.
Bye
Mild Shock schrieb:
Hi,
Here I am not agreeing with John W. Lloyd,
when in his 2nd monograph Logic for Learning,
he proposes basic terms to cover
Logic for Learning
https://users.cecs.anu.edu.au/~jwl/LogicforLearning/
certain if-then-else lambda terms. We can also
do without if-then-else, if we have a complete
key domain and do not model a default.
The translation is as follows:
dict_arrow({D}, (X,Y) => Z) :- dict_arrow(D, X, Y, Z).
dict_arrow(K:V, X, Y, (X = K, Y = V)).
dict_arrow((A,B), X, Y, (C;D)) :-
dict_arrow(A, X, Y, C),
dict_arrow(B, X, Y, D).
They work as expected:
?- dict_arrow({foo:123,bar:baz}, _X), call(_X, foo, Y).
Y = 123;
fail.
?- dict_arrow({foo:123,bar:baz}, _X), call(_X, jack, Y).
fail.
And these dicts even allow something that Mozilla
arrow functions currently cannot do. They can yield,
i.e. act as enumerators. Here an example enumerating keys:
?- dict_arrow({foo:123,bar:baz}, _X), call(_X, Y, _).
Y = foo;
Y = bar.
Bye
Mild Shock schrieb:
Hi,
Functional requirement:
?- Y = g(_,_), X = f(Y,C,D,Y), term_singletons(X, L),
L == [C,D].
?- Y = g(A,X,B), X = f(Y,C,D), term_singletons(X, L),
L == [A,B,C,D].
Non-Functional requirement:
?- member(N,[5,10,15]), time(singletons(N)), fail; true.
% Zeit 1 ms, GC 0 ms, Lips 4046000, Uhr 11.08.2025 01:36
% Zeit 3 ms, GC 0 ms, Lips 1352000, Uhr 11.08.2025 01:36
% Zeit 3 ms, GC 0 ms, Lips 1355333, Uhr 11.08.2025 01:36
true.
Can your Prolog system do that?
P.S.: Benchmark was:
singletons(N) :-
hydra2(N,Y),
between(1,1000,_), term_singletons(Y,_), fail; true.
hydra2(0, _) :- !.
hydra2(N, s(X,X)) :-
M is N-1,
hydra2(M, X).
Bye
Hi,
That Mozilla has no yield in their arrow functions,
is documented here:
Arrow functions cannot use yield within their body
and cannot be created as generator functions.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
So the Dogelog Player arrow functions are the
next step in short function literals. They offer the
beauty of unification and backtracking.
We made the keys example to show backtracking:
?- dict_arrow({foo:123,bar:baz}, _X), call(_X, Y, _).
Y = foo;
Y = bar.
But this example suffers from a spurious choice point:
?- dict_arrow({foo:123,bar:baz}, _X), call(_X, foo, Y).
Y = 123;
fail.
If we put the arrow function for the dict, into a static
clause, Dogelog Player will do an ahead of time compilation
of the arrow functions, and the spurious choice point goes away:
?- [user].
lloyd(((X,Y) => (X = foo, Y = 123; X = bar, Y = baz))).
^Z
?- lloyd(_D), reference(_D).
true.
?- lloyd(_D), call(_D, foo, X).
X = 123.
Bye
Mild Shock schrieb:
Hi,
Here I am not agreeing with John W. Lloyd,
when in his 2nd monograph Logic for Learning,
he proposes basic terms to cover
Logic for Learning
https://users.cecs.anu.edu.au/~jwl/LogicforLearning/
certain if-then-else lambda terms. We can also
do without if-then-else, if we have a complete
key domain and do not model a default.
The translation is as follows:
dict_arrow({D}, (X,Y) => Z) :- dict_arrow(D, X, Y, Z).
dict_arrow(K:V, X, Y, (X = K, Y = V)).
dict_arrow((A,B), X, Y, (C;D)) :-
dict_arrow(A, X, Y, C),
dict_arrow(B, X, Y, D).
They work as expected:
?- dict_arrow({foo:123,bar:baz}, _X), call(_X, foo, Y).
Y = 123;
fail.
?- dict_arrow({foo:123,bar:baz}, _X), call(_X, jack, Y).
fail.
And these dicts even allow something that Mozilla
arrow functions currently cannot do. They can yield,
i.e. act as enumerators. Here an example enumerating keys:
?- dict_arrow({foo:123,bar:baz}, _X), call(_X, Y, _).
Y = foo;
Y = bar.
Bye
Mild Shock schrieb:
Hi,
Functional requirement:
?- Y = g(_,_), X = f(Y,C,D,Y), term_singletons(X, L),
L == [C,D].
?- Y = g(A,X,B), X = f(Y,C,D), term_singletons(X, L),
L == [A,B,C,D].
Non-Functional requirement:
?- member(N,[5,10,15]), time(singletons(N)), fail; true.
% Zeit 1 ms, GC 0 ms, Lips 4046000, Uhr 11.08.2025 01:36
% Zeit 3 ms, GC 0 ms, Lips 1352000, Uhr 11.08.2025 01:36
% Zeit 3 ms, GC 0 ms, Lips 1355333, Uhr 11.08.2025 01:36
true.
Can your Prolog system do that?
P.S.: Benchmark was:
singletons(N) :-
hydra2(N,Y),
between(1,1000,_), term_singletons(Y,_), fail; true.
hydra2(0, _) :- !.
hydra2(N, s(X,X)) :-
M is N-1,
hydra2(M, X).
Bye
Hi,
It seems there is a gap between doing certain
things , like for example prototype-based programming
where we would store arrow functions in dicts.
To reasoning about. For eample I find:
Bryan Ford: Dictionary Abstractions and
Implementations in Isabelle/HOL
https://bford.info/isabelle/dict/
Lars Hupel: Certifying Dictionary Construction
in Isabelle/HOL
https://lars.hupel.info/pub/dict.pdf
The Bryan Ford work is in the level of Logtalk
value objects. The Lars Hupel work tells me:
4 Limitations
"Specifiedness A particularly thorny issue is
presented by functions that return other
functions. While currying itself is a common
idiom in functional programming, manipulation
of partially-applied functions would require a
non-trivial data flow analysis."
So what now? Can we not more broadly ahead
of time compile them? Will Isabelle/HOL stay in
limbo, no JavaScript backend, no Go backend.
Bye
| Sysop: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,076 |
| Nodes: | 10 (1 / 9) |
| Uptime: | 81:17:34 |
| Calls: | 13,805 |
| Files: | 186,990 |
| D/L today: |
7,204 files (2,402M bytes) |
| Messages: | 2,443,304 |