Perhaps  i.~  is a viable line of attack.  It's quite fast.   Here are a few 
variations on a theme:

    ({ ((_1 + #@:[ +/\@:~: (i.i.)) 1 + >./)  ) i.~ y        NB.   A
    ({ (* _1++/\)@:(~:)@:({.~      1 + >./)  ) i.~ y        NB.   B
    ({i.@:#@:]`]`(#&0@:(1+>./@:]))}~@:~.@:({.~1+>./)) i.~y  NB.   C

For the subdomain where the nub of  y  is clustered at the front, these are 
faster than  (~.y) i. y  .  But for  y  as given (where  >./i.~y  is normally 
large), the nub method is faster.


       0.000128787     NB.  (~.y) i. y
       0.000369041     NB.  A
       0.00032546      NB.  B
       0.000344737     NB.  C

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

Reply via email to