I don’t agree, it does not proceed further.

   ([x] u^:v^:_ y) will actually stop when v returns 0 (does not skip or 
continue executing)

Here is a simple way to confirm this using a function f to do 2&* but which 
also uses ’smoutput’ to output to the session log (print intermediate results).

f=: verb define
 smoutput r=:2*y
 r
)

   f 5
10         NB. Intermediate print using smoutput
10.        NB. Result of f

Test it…
   a=:f 5
5.          NB. It still prints within f via smoutput

So now …
   f^:(10>])^:3 ] 1
2                       }
4                       } Intermediates from smoutpout (f called 3 times)
8                       }
8                      NB. Result returned (ran to completion)
f^:(10>])^:4 ] 1
2                       }
4                       } Intermediates from smoutpoutn (f called 4 times)
8                       }
16                     }
16                     NB. Result returned (ran to completion)
f^:(10>])^:8 ] 1
2                       }
4                       } Intermediates from smoutput (f called 4 times)
8                       }
16                     }
16                     NB. Result returned (aborted, so it stopped short and 
did not proceed further)

HTH, Rob


> On 26 May 2020, at 6:40 pm, Anton Wallgren <[email protected]> wrote:
> 
> On closer inspection, f^:v^:n doesn’t seem to work (as I want it to). What it 
> does is to skip evaluation each time v y returns 0. While this would work in 
> my situation, as the stopping condition would remain true, it would of course 
> be unnecessary (and inefficient) to keep checking this for the remainder of 
> the iterations.
> 
> Thanks, Anton Wallgren

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

Reply via email to