#! /usr/bin/env ijconsole
  dot =: 3 : '''.'' 1!:3 <''/proc/self/fd/1'''
  
  hardwork =: 3 : 0
    n =. 0
    for_i. i.100 do.
      dot''
      n =. n + 2 | !!8x
    end.
    n
  )
  echo hardwork''
  exit 0

!!8x takes about 6s to run on my machine so you can see that this
prints dots without a newline and without getting cached. This works
interactively and when piped to a file (1!:2 will also seem to work
interactively, but won't be as kind to piped output). Depending on what
you're doing it might be better to write to /proc/self/fd/2 (stderr).
You can also make the writes conditional on isatty 1 (or 2 if you're
writing to that), so that you don't get this kind of human-oriented
output when a human isn't looking. An isatty conditional would
incidentally suppress this output in JQt, where you'd just get an
interface error from it otherwise.

On Sun, 2020-01-26 at 19:33 +0300, 'Sergey Kamenev' via Programming
wrote:
> 26.01.2020 19:15, Brian Schott пишет:
> > 'aaa' empty@(1!:2) 4
> 
> Thank you, Brian!
> 
> '.' empty@(1!:2) 4
> 
> Really no new line after this verb in session mode!
> 
> But I found another problem.
> Output of this verb is cached in some buffer and displayed only after
> invoking 'echo' verb.
> I see this in ./scripts.ijs mode (on Linux)
> 
> I has coding displaing dots in long loop and this caching make me
> nervous:
> I don't see signs of work of my program.
> 
> Sergey.
> 
> 
> -------------------------------------------------------------------
> ---
> For information about J forums see 
> http://www.jsoftware.com/forums.htm

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

Reply via email to