]x=. 0 4 5 e.~ i.3 3
1 0 0
0 1 1
0 0 0
   I.x
0 0
1 2
0 0

I am genuinely curious: is the latter result of use to anyone?

Why not this instead?

   where=. , # $ #: i.@#@,
   where x
0 0
1 1
1 2

 -E

P.S. current scheme throws away information senselessly.

   ]y=. 3 3 $ 2 0 0  0 1 1  0 0 0
2 0 0
0 1 1
0 0 0
   x (-: , -:&:I.) y
0 1

P.P.S. proposed definition is effectively Dyalog's 'where', but without nesting.

       ⊢x← 0 4 5 ∊⍨ 3 3⍴⍳9
 1 0 0
 0 1 1
 0 0 0
       ⍸x
  0 0  1 1  1 2

P.P.P.S. a truly horrifying fact that was pointed out to me on lobsters (a webforum): if you only care about the boolean case, you may also use:

4&$.@$.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to