On 2 Nov 2006 at 12:51, Leigh J. Halliwell said:

> Dear J Forum:
> 
> Thanks for your suggestions.  But I worked around it, and arrived at just
> what I needed:
> 
> BoxAccTo =. 4 : '((;z) <;.1 >x) (I. y>0)} z =. y{. each 1'
> 
> It's not as pretty, and can't be tacitly coded.  But I wonder how its
> efficiency compares with the earlier attempt.

My results using
   ]xx=.+/pp=.?1000$6
2486

1. My solution of the 31st
   BoxAccTo=.13 :'((+/\*])0<x){a:,(I.x)</.y'
   ts 'xx BoxAccTo pp'
0.0005835937249 83712

2. Your solution above
   aBoxAccTo =. 4 : '((;z) <;.1 >x) (I. y>0)} z =. y{. each 1'
   ts 'xx aBoxAccTo pp'
0.002174298689 376704

3. R.E. Boss's tacit version
   bBoxAccTo =. (([: ; ] {.&.> 1:) <;.1 >@[)`([: I. ] > 0:)`(] {.&.> 1:)}
   ts 'xx bBoxAccTo pp'
0.004131251318 372288

4. Ewart Shaw's solution from the 31st
   JEHS =. [EMAIL PROTECTED] #^:_1 (</.~ (# [EMAIL PROTECTED]))
   ts 'xx JEHS pp'
0.0005062095881 120384

which seems to be the winner.

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

Reply via email to