Bill

This is basically an old APL idiom;
  >./\([EMAIL PROTECTED])0 1 0 1 0 0 1 0 0 0 1 0
0 1 1 3 3 3 6 6 6 6 10 10
or
  (>./\@:[EMAIL PROTECTED])0 1 0 1 0 0 1 0 0 0 1 0
0 1 1 3 3 3 6 6 6 6 10 10
if you want it all in one verb
or, using a j-only primitive
  (>./\@:(#^:_1 I.))0 1 0 1 0 0 1 0 0 0 1 0
0 1 1 3 3 3 6 6 6 6 10 10


Mike

bill lam wrote:
A related question, how to transform it into index to the firststone of the
group, assuming at least a '1' exist,
eg. from this boolean array
  0 1 0 1 0 0 1 0 0 0 1 0
I want the array
  0 1 1 3 3 3 6 6 6 6 10 10

I can do it but not elegant.

regards,

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to