Wait a minute... how would you know how long to make the result of I.^:_1 ?
Never mind. Henry Rich > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Henry Rich > Sent: Wednesday, November 05, 2008 7:58 AM > To: 'Programming forum' > Subject: RE: [Jprogramming] cut on length > > Another approach would be to implement I.^:_1 - not a bad > idea in its own right - and then > > (I.^:_1@(|.!.0) x) <;.1 y > > I.^:_1 would run in linear time. > > Henry Rich > > > -----Original Message----- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of Roger Hui > > Sent: Wednesday, November 05, 2008 3:06 AM > > To: Programming forum > > Subject: Re: [Jprogramming] cut on length > > > > It has been a long quest in APL/J to make > > x e. y as fast as 1 x1}y1 . The quest continues. > > > > I must say that I like Brian Schott's solution (I.x)</.y > > the best. The implementation should reward concise > > solutions and I'll see if I can make that solution faster. > > > > > > > > ----- Original Message ----- > > From: "Sherlock, Ric" <[EMAIL PROTECTED]> > > Date: Tuesday, November 4, 2008 22:57 > > Subject: RE: [Jprogramming] cut on length > > To: Programming forum <[email protected]> > > > > > ---Roger Hui wrote: > > > > f0=: 4 : '(I.x)</.y' > > > > f1=: 4 : '((i.#y) e. +/\0,x) <;.1 y' > > > > > > > > x=: 1+1e4 [EMAIL PROTECTED] 100 > > > > y=: t {~ (+/x) [EMAIL PROTECTED] #t=. 'barack obama' > > > > > > > > x (f0 -: f1) y > > > > 1 > > > > ts=: 6!:2 , 7!:[EMAIL PROTECTED] > > > > > > > > ts 'x f0 y' > > > > 0.0700156 1.09591e7 > > > > ts 'x f1 y' > > > > 0.00778395 4.20992e6 > > > > > > When I saw Brian's solution I wasn't going to post mine - his > > > was so much simpler (BTW I have only used monadic I. to turn a > > > boolean into an index of 1s and hadn't realised what it did with > > > integers). Roger's post prompted me to time mine and the result > > > surprised me. > > > > > > f2=: 4 : '(1 (<:+/\x)} (#y)$0) <;.2 y' > > > x (f1 -: f2) y > > > 1 > > > 50 ts 'x f0 y' > > > 0.030942459167 10976256 > > > 50 ts 'x f1 y' > > > 0.0077791269561 4227072 > > > 50 ts 'x f2 y' > > > 0.0060425808308 2654272 > > > ---------------------------------------------------------------------- > > For information about J forums see > http://www.jsoftware.com/forums.htm > > > > ---------------------------------------------------------------------- > For information about J forums see > http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
