I see Pablo has just replied,  but here's a similar/same approach, as a tacit 
expression:

   b =. 0=3|i.2 3 4
   ($#:I.@,)  b
0 0 0
0 0 3
0 1 2
0 2 1
1 0 0
1 0 3
1 1 2
1 2 1
Might be of use,

Mike

Sent from my iPad

> On 11 Dec 2023, at 10:06, LdBeth <andp...@foxmail.com> wrote:
> 
> I've been running to too many situations that I uses  4$.$.y  a lot to
> get indexes of all non zero elements to an array, I wonder if there
> are any alternative ways to do that in J, especially when  y  is a
> boolean array.
> 
> Also monadic I. only works for 1D array, while  ⍸ from APL works
> for higher dimension cases, how to implement this in J?
> 
> LdBeth
> 
> ----------------------------------------------------------------------
> 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