When going for speed, there's two basic approaches: (1) try minor variations on the theme - rearrange to see if you can eliminate anything, or to incorporate any known special code,
(2) rewrite from scratch and see if that's faster. Personally, I don't see any way to make that one any faster, though I can rewrite it: rg=: 3 : '(y-g)+(0*g) (~.r)}~ #/.~ r=. ?(#y)#~ +/g=.*y' I can, of course suggest alternate "from scratch" rewrites - but that's just by referring to previous posts in this thread. I don't know if this helps, -- Raul On Wed, Jul 26, 2017 at 4:44 PM, Jimmy Gauvin <jimmy.gau...@gmail.com> wrote: > Hi, > > this function seems reasonably fast but I think it could be re-arranged to > be a bit more compact, > > Would anyone have some tips as how to go about this? > > rg =: 3 : '(y-g) + (r #/. r) (~. r =. ? (+/ g =. y>0)$ $y) } 0 $~ $y' > > > ts 'rg ^:10000 ] 400$100' > > 0.209447 38272 > > > ts 'rg ^:100000 ] 400$100' > > 2.10048 38272 > > > > Thanks > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm