A fully tacit solution would encapsulate the predicate too, here parenthesized for emphasis:
($ #: [: I. [: (5&=) ,) (>:i.8)* 8 8 $ 1j2 # 1 4 1 4 4 4 7 Dec 11, 2023, 17:01 by programm...@jsoftware.com: > 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 > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm