BoxAcc=: <;.1~ [:([EMAIL PROTECTED]: e.])[:+/\0&,
X=i.10 and P= 1 2 3 4 then
(i.10)(<;.1~ [:([EMAIL PROTECTED]: e.])[:+/\0&,)1 2 3 4
+-+---+-----+-------+
|0|1 2|3 4 5|6 7 8 9|
+-+---+-----+-------+
R.E. Boss
-----Oorspronkelijk bericht-----
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Leigh J. Halliwell
Verzonden: dinsdag 31 oktober 2006 13:39
Aan: 'Programming forum'
Onderwerp: [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