]> Repositorios git - scryer-prolog.git/commitdiff
Merge pull request #371 from notoria/sleep
authorMark Thom <[email protected]>
Mon, 20 Apr 2020 00:41:33 +0000 (21:41 -0300)
committerGitHub <[email protected]>
Mon, 20 Apr 2020 00:41:33 +0000 (21:41 -0300)
Added the sleep predicate

1  2 
src/prolog/lib/time.pl

index 97358a7d8cbbce9862b638a4d18bdda43fd0d218,1a5649592ed1cfe21cd5ef1d2cb17a24316e466d..b41d958a79ff4fe8b2973486a1bf427bc783d5f7
  :- 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),
 -        Goal,
 +        setup_call_cleanup(true,
 +                           (   Goal,
 +                               report_time(T0)
 +                           ),
 +                           report_time(T0)).
 +
 +report_time(T0) :-
          '$cpu_now'(T),
          Time is T - T0,
          (   bb_get('$first_answer', true) ->