y=: 1e5 [EMAIL PROTECTED] 900
et'(~.y)i.y'
0.0011738756
et'(]{~.([EMAIL PROTECTED]@[`[`])} 0{.~#) y'
0.0027278706
((~.y)i.y)-:(]{~.([EMAIL PROTECTED]@[`[`])} 0{.~#) y
1
R.E. Boss
> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED] [mailto:programming-
> [EMAIL PROTECTED] Namens Dan Bron
> Verzonden: vrijdag 25 mei 2007 14:57
> Aan: Programming forum
> Onderwerp: Re: [Jprogramming] index in nub
>
> Roger wrote:
> > (~.y)i.y finds the indices of y in the nub of y .
> > Can you do it faster?
>
> Not yet. But here's a fun approach:
>
> db0 =: (/:~&:; ((#~ #)~&.> i.@:#))@:(</. [EMAIL PROTECTED])
>
> rewriting that to leverage more special code, at the cost of a slight
> redundancy:
>
> db1 =: I.@:(#/.~) /: ;@:(</. [EMAIL PROTECTED])
>
> > y=: 1e4 [EMAIL PROTECTED] 900
> > 6!:2 '(~.y) i. y'
> > 0.000147784
> >
> > 6!:2 ',I.|:=y'
> > 0.186556
>
>
> y=: 1e4 [EMAIL PROTECTED] 900
>
> 6!:2 '(~.y) i. y'
> 0.000170692
>
> 6!:2 ',I.|:=y'
> 0.1902
>
> 6!:2 'db0 y'
> 0.00259726
>
> 6!:2 'db1 y'
> 0.00141219
>
> So, only an order of magnitude slower at this point. I'll try to come up
> with something faster during the day.
>
> -Dan
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm