This works correctly for me on Windows.  The code for SYS_MACINTOSH waits for (60*+/y) TickCount ticks; other platforms do sleep(1000) for (<. +/ y) repetitions, followed by one final sleep to get the remnant of time.

Can it be that your OS is using the Windows code but sleep() is returning fast?  If so, if you just do

6!:3 ] 10

you should see it return very quickly.

Henry Rich

On 7/3/2018 2:12 PM, Raul Miller wrote:
http://www.jsoftware.com/help/dictionary/dx006.htm says:

6!:3 y Delay. Delay execution for y seconds. For example, 6!:3 (2.5)

but today I ran into an example where that did not seem to be what it was doing.

Rather than go into the full complexity of that example, let's try
doing a two second delay in ten steps:

    delay=: 6!:3"0
    timespacex 'delay 10#0.2'
3.6e_5 2432

Pretty fast right? Two seconds compressed into less than a millisecond...

My guess is that J's using an api mechanism (sleep) which only
supports integer seconds and it's discarding the fractions.

As an alternative:

Linux/OSX/etc.: nanosleep
Windows: sleep (has millisecond precision)

(In other words, all I really needed to do to fix this problem was
switch operating systems.)

Thanks,



---
This email has been checked for viruses by AVG.
https://www.avg.com

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to