I want to limit "executing" of algorithm in prolog. Can you give me a hint, how to do it? I have found this predicate: call_with_time_limit How can I catch the time_limit_exceeded exception? Thanks
UPDATE:
I am trying it this way:
timeout(t) :-
catch(call_with_time_limit(t, sleep(5)), X, error_process(X)).
error_process(time_limit_exceeded) :- write('Timeout exceeded'), nl, halt.
error_process(X) :- write('Unknown Error' : X), nl, halt.
but noting happend when I call timeout(1):
prolog :-
timeout(1),
but when I do it this way:
runStart :- call_with_time_limit(1, sleep(5)).
timeout(1) :-
catch(runStart, X, error_process(X)).
error_process(time_limit_exceeded) :- write('Timeout exceeded'), nl, halt.
error_process(X) :- write('Unknown Error' : X), nl, halt.
and again call timeout(1) everything is fine. Why? Thanks UPDATE 2:
Problem solved, it is necessary to have predcate "argument" with upper case...