@@ -3,17 +3,26 @@
|
||||
Part of Scryer Prolog.
|
||||
|
||||
This library provides predicates for reasoning about time.
|
||||
sleep/1 should be implemented here, sleeping for a number of seconds.
|
||||
In addition, this library should provide reasoning about time stamps.
|
||||
Reasoning about time stamps would be a useful addition, for example
|
||||
by obtaining the current time, comparing and formatting it.
|
||||
|
||||
'$cpu_new' can be replaced by statistics/2 once that is implemented.
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
:- module(time, [time/1]).
|
||||
:- module(time, [sleep/1, time/1]).
|
||||
|
||||
:- use_module(library(format)).
|
||||
:- use_module(library(iso_ext)).
|
||||
|
||||
sleep(T) :-
|
||||
builtins:must_be_number(T, sleep),
|
||||
( T < 0 ->
|
||||
throw(domain_error(not_less_than_zero, T))
|
||||
; T > 0xfffffffffffffbff ->
|
||||
throw(domain_error(not_great_than_0xfffffffffffffbff, T))
|
||||
; '$sleep'(T)
|
||||
).
|
||||
|
||||
time(Goal) :-
|
||||
'$cpu_now'(T0),
|
||||
setup_call_cleanup(true,
|
||||
|
||||
Reference in New Issue
Block a user