You are right, the expressions differ in rank and so are not equivalent.
But thus that result in a difference in tindexof2? 
Left rank of tindexof2is _ and rank of {:@$&.> is 0, so I doubt.


R.E. Boss



> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED] [mailto:programming-
> [EMAIL PROTECTED] Namens Roger Hui
> Verzonden: vrijdag 12 oktober 2007 17:16
> Aan: Programming forum
> Onderwerp: Re: [Jprogramming] Performance of case-insensitive lookup
> 
> I have my nitpicker hat on today:  They are not equivalent
> because the former has unbounded rank whereas the latter
> has rank 0.  This makes a difference in tindexof2:
> 
> > tindexof2=: ([,&.>]) tindexof {:@$&.>@([,&.>]) {."1&.>]
> 
> wherein you either have to say ,&.>"_ or use @:
> 
> 
> 
> ----- Original Message -----
> From: "R.E. Boss" <[EMAIL PROTECTED]>
> Date: Friday, October 12, 2007 6:02
> Subject: RE: [Jprogramming] Performance of case-insensitive lookup
> To: 'Programming forum' <[email protected]>
> 
> >
> >  [,&.>] is equivalent to ,&.>
> >
> >
> > R.E. Boss
> >
> >
> > > -----Oorspronkelijk bericht-----
> > > Van: [EMAIL PROTECTED] [mailto:programming-
> > > [EMAIL PROTECTED] Namens Sherlock, Ric
> > > Verzonden: vrijdag 12 oktober 2007 14:23
> > > Aan: Programming forum
> > > Onderwerp: RE: [Jprogramming] Performance of case-insensitive lookup
> > >
> > > ---Sherlock, Ric wrote
> > > > --bill lam wrote:
> > > > > Sherlock, Ric wrote:
> > > > > > My solutions as follows:
> > > > > >    textend=: {:@$&.>@[ {."1&.> ]
> > > > > >    pplinv textend pinv
> > > > > > +-------+------+
> > > > > > |Joan   |Saxon |
> > > > > > +-------+------+
> > > > > >
> > > > > >    pplinv tindexof pplinv textend pinv
> > > > > > 4
> > > > > >
> > > > >
> > > > > A potential gotcha is that text in pinv is longer than
> > pplinv, your
> > > > > solution will trim pinv to shorter length but there should
> > > > not be any
> > > > > match because pinv is longer than pplinv.  Of course
> > if it is known
> > > > > before hand that pinv must be shorter than pplinv, there
> > will be no
> > > > > problem.
> > > >
> > > > Very true!
> > >
> > > I think this solves that problem:
> > > tindexof2=: ([,&.>]) tindexof {:@$&.>@([,&.>]) {."1&.>]
> > >
> > >   p3=: 'Josephine';'Saxon'
> > >   p3inv=: ifa mfv p3
> > >
> > > Basically I append the names to be looked up to the lookup
> > table and
> > > then extend the names to be looked up by the widths of the appended
> > > lookup table. The lookup is done on the appended table.
> > >   ppl i. p3
> > > 500
> > >   pplinv tindexof2 p3inv
> > > 500
> > >
> > > Of course if there are more than 1 names to be looked up, the
> > result may
> > > include indices greater than #ppl, but will still provide the
> > correct> answer to the normal "is found" test i.e. the resulting
> > index is not
> > > less than #ppl
> > >   (#ppl)>  ppl i. p,p3
> > > 1 0
> > >   (ttally pplinv)> pplinv tindexof2 pinv ,each p3inv
> > > 1 0
> > >
> > > Performance is only a bit worse:
> > >    ts '(tolower each pplinv) tindexof1 (tolower
> > each p2inv)'
> > > 0.000125434936563 8320
> > >    ts '(tolower each pplinv) tindexof2 (tolower
> > each p2inv)'
> > > 0.000133257159779 8320
> > >
> > > The phrase [,&.>] is used twice so I wonder if it is possible to
> > > simplify tindexof2 further?
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

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

Reply via email to