This repository has been archived on 2025-09-23. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
2025LogProg-project-GhentPr.../examples/meta/continuations.pl
2025-05-09 15:08:42 +02:00

22 lines
516 B
Prolog

% Based on
% https://occasionallycogent.com/continuations_in_prolog/
test(Cont, Term) :-
writeln("Inside test"),
reset(test_, Term, Cont),
writeln("After reset").
test_ :-
writeln("Entering reset"),
shift(Y),
X is 1 + (2 * Y),
write("In test X = "), write(X), writeln("; done").
main :-
test(Cont, Term),
\+ \+ ( writeln("Calling Cont(2)"),
Term = 2, call(Cont)),
\+ \+ ( writeln("Calling Cont(4)"),
Term = 4, call(Cont)).
:- initialization(main).