The last solution in October, http://www.jsoftware.com/pipermail/programming/2006-November/003853.html is faster: 'X Y'=:10000,@$&.>11 12 13 14 15;&,: 3 0 2 ts 'X BoxAccTo Y' 0.045380196 4742464 ts 'X ([EMAIL PROTECTED] #^:_1 (</.~ I.)) Y' 0.016437219 3526464
(X BoxAccTo Y) -: ([EMAIL PROTECTED] #^:_1 (</.~ I.)) Y 1 R.E. Boss -----Oorspronkelijk bericht----- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Henry Rich Verzonden: vrijdag 20 april 2007 2:18 Aan: 'Programming forum' Onderwerp: RE: [Jprogramming] Boxing Data Converting the operand to the form used by ;.0 : BoxAccTo =: (<;.0~ ,."1) (,.~ |.!.0@(+/\)) 11 12 13 14 15 BoxAccTo 3 0 2 +--------++-----+ |11 12 13||14 15| +--------++-----+ +/ #@> 11 12 13 14 15 BoxAccTo 3 0 2 5 Henry Rich > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Leigh > J. Halliwell > Sent: Thursday, April 19, 2007 8:02 PM > To: 'Programming forum' > Subject: [Jprogramming] Boxing Data > > Dear J Forum: > I want to box a vector of numbers and want to box according to another > vector that tells how many to put in the boxes. For example, > 11 12 13 14 15 > BoxAccTo 3 0 2 means (11 12 13); ace; (14 15). It's > important that zeroes > produce empty boxes. Also, +/ of the second vector must > equal # of the > first. > I've created a tacit function that does the job. However, I > suspect that > it's inefficient. In particular, it doesn't use the cut > primitive (;), > because cut doesn't like boxing 0 elements. So I hope that > you can come up > with simpler, more efficient tacit functions. Thanks. > Sincerely, > Leigh > > ---------------------------------------------------------------------- > 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
