sleep function (sleep for x seconds) (Maxima)

385 views Asked by At

This function sleeps for x seconds, is there a better sleep function, perhaps in fewer lines or that uses less memory (e.g. no 'expand' line)?

Also, it could be more accurate, although for my needs the accuracy is sufficient.
EDIT: My main use is for a short delay, to view images in the main window as they are created.

I know that '?\*autoconf\-version\*;' can give the Maxima version number, so maybe there is some undocumented way to sleep for a set period of time.

sleep(x) := for i : 1 do
(
if (i = 1) then (t:elapsed_real_time()),
if (elapsed_real_time() - t >= x) then return(),
expand ((a + b)^500)
)$

to test the sleep function:

print(0, timedate())$
sleep(1)$
print(1, timedate())$
sleep(2)$
print(2, timedate())$
sleep(3)$
print(3, timedate())$
sleep(4)$
print(4, timedate())$
sleep(5)$
print(5, timedate())$

EDIT 2: some useful code (original problem solved)

:lisp (sleep 1)
?sleep(1)$
?sleep(1);
sleep(x) := ?sleep(x);

EDIT 3: some useful links

[Lisp and Maxima]
Maxima 5.39.0 Manual: 37. Program Flow
http://maxima.sourceforge.net/docs/manual/maxima_37.html

[How to suppress the output of lisp function]
Maxima -- GPL CAS based on DOE-MACSYMA / Mailing Lists
https://sourceforge.net/p/maxima/mailman/message/33016361/

1

There are 1 answers

1
Fermat65537 On BEST ANSWER

Maxima is written in lisp, you can use a lisp command:

:lisp (sleep 1)