g1=: ~. (i. { [EMAIL PROTECTED]) ]
----- Original Message -----
From: John Randall <[EMAIL PROTECTED]>
Date: Tuesday, October 28, 2008 16:53
Subject: Re: [Jprogramming] Index of first one in columns
To: Programming forum <[email protected]>
> Roger Hui wrote:
> > icol1=: # - +/@(+./\)@(1&=)
> >
> > See also:
> > http://www.jsoftware.com/jwiki/Essays/Collatz_Conjecture
>
> Thanks, Roger!
>
> Perhaps you could also help me on another question from this
> context. I
> have a function f to evaluate on an array a. Since f is
> expensive, I
> evaluate it on the nub and distribute the results. The NUB
> adverb in the
> Dictionary does not work because the arrays are too big, so I
> use another
> verb g which is much faster, but not optimal.
>
> For example:
>
> a=:10 | i.100
> f=:*:
> g=: (~. i. ]) { f @:~.
> (f-:g) i.100
> 1
>
> I know I ought to be able to do better by only evaluating the
> nub once,
> but I can't see how to do it.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm