Order functions by growth rate

EDIT: I’ve revised my answer based on the comments I’ve got this HW question which asks me to order a list of functions by their growth rate. The question also asks to indicate which ones have the same growth rate. Here are the functions: N sqrt(N) N^1.5 N^2 N log N N log log N … Read more

How to create an accurate timer in javascript?

Why is it not accurate? Because you are using setTimeout() or setInterval(). They cannot be trusted, there are no accuracy guarantees for them. They are allowed to lag arbitrarily, and they do not keep a constant pace but tend to drift (as you have observed). How can I create an accurate timer? Use the Date object instead to get the (millisecond-)accurate, current time. Then base … Read more

Lua Program Delay

The os.clock function returns the number of seconds of CPU time for the program. So the sleep function of yours waits for n seconds, if you need to delay 2 minutes, just call: Note that there are some better solutions to implement sleep functions other than busy waiting, see Sleep Function for detail.

tech