I appreciate your effort demonstrate on how to derive reusable code in J.
It is important to know how to adapt existed solutions for different needs.
To me knowing that I can use the shape of the array to decode (#:) indices
generated by I. is a good enough respond to my question. So I also tha
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
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 under
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
> expr
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 wrote:
>
> I've been running to too many s
($ #: I.@,) y
Henry Rich
On 12/11/2023 5:06 AM, LdBeth 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 monadi
index =: $ #: [: I. ,
index ? 2 4$2
0 0
1 0
1 3
index ? 2 4 5$2
0 0 0
0 0 1
0 0 2
0 0 3
0 1 1
0 2 1
0 2 3
0 2 4
0 3 2
1 0 0
1 0 1
1 0 2
1 0 4
1 1 1
1 1 3
1 2 1
1 2 2
1 2 4
1 3 0
1 3 1
1 3 2
On Mon, Dec 11, 2023 at 11:06 AM LdBeth wrote:
> I've been running to too many
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 d