gprolog
gprolog copied to clipboard
hand written C code lacks some garbage collection.
Try this:
test(X) :- append(Y, X, [1,2,3|Y]).
I get that GNU Prolog cannot run it indefinitely:
?- test(X).
X = [1,2,3] ? ;
X = [2,3,1] ? ;
X = [3,1,2] ?
?- test(X), fail; true.
%%% Dialog Window with global stack overflow
%%% After dismissing the Dialog Window GNU Prolog exists
Whereas SWI-Prolog can run it indefinitely:
?- test(X).
X = [1, 2, 3] ;
X = [2, 3, 1] ;
X = [3, 1, 2] .
?- test(X), fail; true.
%%% runs indefinitely, you can watch the thread monitor, see how memory is reclaimed
%%% Responds to Ctrl-C and can be aborted, will gracefully return to top-level
Credits go to:
Marquee in Prolog https://stackoverflow.com/questions/77061142/marquee-in-prolog