NB. Fairly similar to Boss's solution:
X=. i.10
P=. 1 2 0 3 0 4
;P{.&.>1 NB. Build basic partition vec,
1 1 0 1 0 0 1 0 0 0 NB. ignoring empties for now.
$;P{.&.>1 NB. Correct length
10
X<;.1~;P{.&.>1 NB. OK, now put empties into this
+-+---+-----+-------+
|0|1 2|3 4 5|6 7 8 9|
+-+---+-----+-------+
(P~:0)exp X<;.1~;P{.&.>1
+-+---++-----++-------+
|0|1 2||3 4 5||6 7 8 9|
+-+---++-----++-------+
exp
#^:_1
On 10/31/06, Ewart Shaw <[EMAIL PROTECTED]> wrote:
On Tue, 31 Oct 2006, R.E. Boss wrote:
>
> #^:_1 was what I was looking for.
>
> Your solution can be shortened further to
> (i. 10) ([EMAIL PROTECTED] #^:_1 (</.~ I.)) 1 2 3 0 4
...
--
Devon McCormick
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm