How would I go about delaying execution in prolog?
I can do threadDelay ms
in Haskell to delay it by ms
milliseconds. Is there any way to do this in prolog?
I mean I could probably just do a bunch of empty queries like
delay(0).
delay(X) :- delay(Y), Y is X - 1.
but that seems like a stupid and wrong idea.
EDIT:
Apparently there's sleep/1
.
However, when I do something like
delayText([H|T]) :- put_char(H), sleep(0.1), delayText(T).
delayText([]).
, sleep will be executed first (so it will sleep for .5 seconds when querying delayText("Hello").
or something) and then it will display all the text at once? How do I prevent this?