Continuations
This commit is contained in:
parent
88c90220fe
commit
026218ddbd
13 changed files with 255 additions and 15 deletions
19
examples/meta/continuations.pl
Normal file
19
examples/meta/continuations.pl
Normal file
|
@ -0,0 +1,19 @@
|
|||
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).
|
Reference in a new issue