From: Mark Thom Date: Mon, 20 Apr 2020 00:41:33 +0000 (-0300) Subject: Merge pull request #371 from notoria/sleep X-Git-Tag: v0.8.123~118 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=c9750fab2c9e8655c6159ab6a48b645ba96dbf83;p=scryer-prolog.git Merge pull request #371 from notoria/sleep Added the sleep predicate --- c9750fab2c9e8655c6159ab6a48b645ba96dbf83 diff --cc src/prolog/lib/time.pl index 97358a7d,1a564959..b41d958a --- a/src/prolog/lib/time.pl +++ b/src/prolog/lib/time.pl @@@ -14,15 -14,18 +14,24 @@@ :- 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) ->