> I wonder if the interpreter should look for > sorted y in x e. y as a special case.
The situation is complicated and depends on the nature of y, the size of x, etc., regarding whether e. or an I.-based solution would be faster. For example: 10 ts 'x e p' vs. 10 ts 'x e. p', for x=: n ?...@$ 9e5 n x e p x e. p ratio 1e3 0.0002692 9.08800e3 0.0051640 1.05133e6 0.05 0.01 1e4 0.0032195 1.31968e5 0.0045147 1.06566e6 0.71 0.12 1e5 0.0076104 5.24378e6 0.0054531 1.18035e6 1.40 4.44 1e6 0.0332176 1.25838e7 0.0057683 2.09786e6 5.76 6.00 1e7 0.2838031 1.38413e8 0.0476312 1.78265e7 5.96 7.76 ----- Original Message ----- From: Roger Hui <[email protected]> Date: Wednesday, May 20, 2009 15:58 Subject: Re: [Jprogramming] Membership using interval index To: Programming forum <[email protected]> > e signals error if the left argument has an > item larger than the largest item in the right: > > 1e9 2e9 e P > |index error: e > | 1000000000 2000000000 e P > > I wonder if the interpreter should look for > sorted y in x e. y as a special case. > > > > ----- Original Message ----- > From: John Randall <[email protected]> > Date: Wednesday, May 20, 2009 13:56 > Subject: [Jprogramming] Membership using interval index > To: Programming forum <[email protected]> > > > I have been trying to write a version of e. for sorted arrays, using > > I. , since it appears to offer performance benefits. My > > attempt is > > the verb e below: > > > > e=:[ = ] {~ I.~ > > > > time=:6!:2 > > P=:i.&.(p:^:_1) 1e6 > > > > 10 time '(i.1000) e P' > > 0.0001042 > > 10 time '(i.1000) e. P' > > 0.0069257 > > > > Is this a sensible approach, or are there better ways to do it? ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
