In the context of  foo^:predicate^:_  not doing 
what I want when  foo  is not one-to-one,
Pepe wrote:
>  The following is a simple practical workaround
>  [use]          foo^:predicate^:big_finite_number
>  [instead of]  foo^:predicate^:_

For those who don't know, the difference is that for finite  N  then  f^:N
will always execute  N  times, regardless of whether the input stabilizes or
not.  This is in contrast to  f^:_  which will stop executing as soon as the
input stabilizes.

The pitfalls here are twofold.  The big one is that  N  might not be large
enough (so the verb will terminate early); this is a result of
saying-what-works as opposed to saying-what-you-mean, in defiance of the
advice to "let the interpreter catch up".

The second pitfall is less nefarious but more likely to occur in practice
(given a sufficiently large N):  f  may be executed too often.  If your code
is tacit (functional), this has no effect but to take "too long".

So if you want to use this workaround, there's a tradeoff between selecting
N  large enough to essentially guarantee a correct answer, but small enough
to not waste your time.  I think Pepe's 1e5 is a suitable choice for most
applications.

-Dan

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

Reply via email to