I don't think you need to check all your code. Just code that is one of the patterns in http://www.jsoftware.com/help/dictionary/special.htm#compsc
+./ and 1&e. do execute the same (or similar) code and are fast. The difference comes in x +./@:> y vs. +./x>y . The former avoids generating the boolean vector (and then does the fast +./ on that). The latter does use the fast code for +./, but first it unavoidably generates x>y . Benchmarks illustrate this point: x=: 1e6 ?@$ 0 y=: 1e6 ?@$ 0 ts 'x +./@:> y' 5.02857e_6 1088 ts '+./x>y' 0.0301787 1.0496e6 ts 'b=: x>y' 0.0732101 1.04922e6 ts '+./b' 9.21905e_6 1088 Even if it has to "go to the end", the special code is faster and leaner (as one'd expect). ts 'x +./@:> 2' 0.0124083 1088 ts '+./x>2' 0.0355378 1.0496e6 ----- Original Message ----- From: Thomas Costigliola <[email protected]> Date: Thursday, October 13, 2011 17:48 Subject: Re: [Jprogramming] Operations on boolean lists To: Programming forum <[email protected]> > Thanks for the heads up. Now I have to check all the 1&e. in my code. > > At least for rank 1 Boolean arguments it seems like +./ and 1&e. > should execute the same code so as not to tax the un-enlightened. > > On Thu, Oct 13, 2011 at 6:40 PM, Roger Hui <[email protected]> wrote: > > +./@E. is backed by special code. Thus: > > > > ts=: 6!:2 , 7!:2@] > > > > b=: 0<1e6 ?@$ 4 > > ts '(42$1) +./@E. b' > > 0.000961575 1600 > > ts '42 (1 e. ([#1:) E. ]) b' > > 0.00308224 1.05018e6 > > > > Another phrase finds the maximum number of > > consecutive 1s: cut where b has a 1 preceded > > by a 0, and sum the cut. > > > > >./ (b>}:0,b) +/;.1 b > > 42 > > ts '>./ (b>}:0,b) +/;.1 b' > > 0.0198919 4.19635e6 > > > > > > > > ----- Original Message ----- > > From: Thomas Costigliola <[email protected]> > > Date: Thursday, October 13, 2011 15:18 > > Subject: Re: [Jprogramming] Operations on boolean lists > > To: Programming forum <[email protected]> > > > >> N (1 e.([#1:)E.]) 1 0 ... > >> > >> On Oct 13, 2011 5:58 PM, "David Vaughan" > >> <[email protected]>wrote: > >> > > >> > How could I test if a boolean list contains at least n > >> consecutive 1's? > >> > > >> > e.g. for 3 consecutive 1's: > >> > > >> > desiredverb 0 1 1 1 0 0 > >> > 1 > >> > desiredverb 0 1 1 0 1 1 > >> > 0 > >> > desiredverb 1 1 1 1 1 0 > >> > 1 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
