I was switching to unicode for the atoms 'quote',
'cons' and 'lambda':
/* we are using
LEFT SINGLE QUOTATION MARK
LATIN LETTER LATERAL CLICK
GREEK SMALL LETTER LAMBDA
*/
:- encoding(utf8).
And then formulating the quine itself via DCG:
/**
* quine(Q):
* The quine test, as DCG.
*/
quine(Q) -->
{sto(Q), freeze(Q, is_expr(Q))},
eval(Q, [], Q).
This gives the following result:
?- between(1, 6, M), quine(Q, [M], [0]), copy_term_nat(Q, H),
numbervars(H, 0, _), write(H), nl, fail; true.
[[λ,A,[ǁ,A,[ǁ,[ǁ,[‘,‘],[ǁ,A,[‘,[]]]],[‘,[]]]]],[‘,[λ,A,[ǁ,A,[ǁ,[ǁ,[‘,‘],[ǁ,A,[‘,[]]]],[‘,[]]]]]]]
etc..
[[[λ,A,[λ,B,[ǁ,B,[ǁ,[ǁ,[‘,‘],[ǁ,B,[‘,[]]]],[‘,[]]]]]],[‘,C]],[‘,[[λ,A,[λ,B,[ǁ,B,[ǁ,[ǁ,[‘,‘],[ǁ,B,[‘,[]]]],[‘,[]]]]]],[‘,C]]]]
etc..
Unfortunately this doesn't work in a thread window in SWI-Prolog,
i.e. using the menu item "Run | New thread". When use listing(eval//3)
I don't see the result:
eval(['‘', A], _, A, B, B).
eval([ǁ, B, F], C, [D|G], A, I) :-
step(A, E),
eval(B, C, D, E, H),
eval(F, C, G, H, I).
eval([λ, A, B], C, [closure, A, B, C], D, D).
Instead I will see the below, although in the main console the listing
works correctly. So the new thread window and the main console
seem to use different widgets or somes uch:
eval(['‘', A], _, A, B, B).
eval([<black box here>, B, F], C, [D|G], A, I) :-
step(A, E),
eval(B, C, D, E, H),
eval(F, C, G, H, I).
eval([<black box here>, A, B], C, [closure, A, B, C], D, D).
Same problem on a 2K display even with the SWI-Prolog main console. :-(
Now I am heating the CPU with a DCG definition of twine:
?- between(1, 6, M), twine(Q, P, [M], [0]),
copy_term_nat(Q-P, H), numbervars(H, 0, _),
write(H), nl, fail; true.
No results so far, but also no crash.
Bye
cycling fan schrieb: