Does not handle empty boxes. X=:i.10 P=:1 2 3 0 4 (P # i.$P) </. X +-+---+-----+-------+ |0|1 2|3 4 5|6 7 8 9| +-+---+-----+-------+
R.E. Boss -----Oorspronkelijk bericht----- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Lett, Christopher F Verzonden: dinsdag 31 oktober 2006 15:32 Aan: Programming forum Onderwerp: RE: [Jprogramming] Boxing according to a Pattern Leigh, I've been using this expression for years. X=. i. 10 P=. 1 2 3 4 (P # i.$P) </. X +-+---+-----+-------+ |0|1 2|3 4 5|6 7 8 9| +-+---+-----+-------+ /Chris Lett -----Original Message----- From: Leigh J. Halliwell [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 31, 2006 7:39 AM To: 'Programming forum' Subject: [Jprogramming] Boxing according to a Pattern Dear J Forum: Given a vector X of n atoms, and a partition P of non-negative integers that sum to n; i.e. n = n1+n2+...+nk, how can I efficiently create a list of k items, whose first atom is the box of the first n1 elements of X, whose second atom is the box of the next n2 elements, etc? Empty boxes (ni=0) must be allowed. I can do this with difficulty; but I suppose that J primitives allow it to be done as a one-line tacit dyadic function X BoxAccTo P. 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
