The array and verb were an example; didn't want to copy anybody's array and boolean mask.
A general purpose solution, to me, is a verb (that generates the mask), not an explicitly defined noun, lines above. It's how I've saved the snippet in my snippets file, and how I use it. Plug-and-play, or hot-swappable come to mind. ({~ ([: <"1 $ #: [: I. 0 = 3 | ,)) i.2 3 4 A or the trivial predicate would be something like 1:"0, generating all the array's 'full' (rank 0? its atoms'? don't know proper wording) indices. Maybe I shouldn't've replied. Dec 11, 2023, 20:01 by programm...@jsoftware.com: > Sorry, Viktor, but I don't see your point. > (>:i.8)* 8 8 $ 1j2 # 1 > generates an integer array, not a Boolean. > > I agree (5&=) yields a boolean, but is it in any way a general-purpose > condition? > > You might note that Henry Rich proposed the same solution to LdBeth's enquiry. > He (HR) might understand what you're driving at! > > Cheers, > > Mike > > On 11/12/2023 17:09, 'Viktor Grigorov' via Programming wrote: > >> 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 byprogramm...@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 seehttp://www.jsoftware.com/forums.htm >>>> >>> ---------------------------------------------------------------------- >>> For information about J forums seehttp://www.jsoftware.com/forums.htm >>> >> ---------------------------------------------------------------------- >> For information about J forums seehttp://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