I came up with:
rbox =: 4 : 0
if. 1=#x do. <y else.
(({.x) <@:{. y) , (}.x) rbox ({.x) }. y
end.
)3 0 2 rbox (11+ i.5) +--------++-----+ |11 12 13||14 15| +--------++-----+ ----- Original Message ---- From: Leigh J. Halliwell <[EMAIL PROTECTED]> To: Programming forum <[email protected]> Sent: Thursday, April 19, 2007 8:02:02 PM 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 Ask a question on any topic and get answers from real people. Go to Yahoo! Answers and share what you know at http://ca.answers.yahoo.com ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
