It appears to only work with integers.
Don Kelly
On 2020-11-15 10:23 a.m., Henry Rich wrote:
On reflection I am not going to implement (4 $. $.) in special code.
The fundamental operation is 'express the numbers in y, which are
elements of (i. #@, x), as index lists into x'. This is achieved
Moreover, (#:~ $)~ makes for a better smiley.
Am 15.11.20 um 19:23 schrieb Henry Rich:
> On reflection I am not going to implement (4 $. $.) in special code.
>
> The fundamental operation is 'express the numbers in y, which are
> elements of (i. #@, x), as index lists into x'. This is achieved b
On reflection I am not going to implement (4 $. $.) in special code.
The fundamental operation is 'express the numbers in y, which are
elements of (i. #@, x), as index lists into x'. This is achieved by
(#:~ $)~
y can have any shape. (4 $. $.) works only on an argument that happens
to h
...@jsoftware.com
Subject: Re: [Jprogramming] Getting indices of matrix elements
/Et tu, R. E.?/
Using $. for this is using a sledgehammer to crack an egg.
Henry Rich
On 11/13/2020 3:00 PM, R.E. Boss wrote:
> $.$.M
> 0 0 │ 1
> 0 1 │ 2
> 0 2 │ 3
> 0 3 │ 4
> 1 0 │ 5
> 1 1 │ 6
> Wow. Just when I think I'm starting to get proficient in the language...
>M (4 $. [: $. =) 6 32 58
One might never stop learning, or relearning J ;)
[Jgeneral] (i. 2 3) i. 4 NB. you know what i mean... how do iget it to
work?!
Dan Bron
http://www.jsoftware.com/pipermail/general/2007-May/0
e prefixes of the
table have lengths 1 2 and 3
#\ i. 3 4
1 2 3
>Date: Fri, 13 Nov 2020 18:05:09 +0100 (CET)
>From: "thomas.bulka via Programming"
>To: programm...@jsoftware.com
>Subject: [Jprogramming] Getting indices of matrix elements
>Message-ID:
>Content-Type:
That's not the "problem", that's the solution. They are the missing indices.
R.E. Boss
-Original Message-
From: Programming On Behalf Of Roger
Hui
Sent: zaterdag 14 november 2020 04:55
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Getting indice
That's the odometer function, no? You have already given us (#:
i.@:(*/)) y . I don't want to do anything to put users in mind of ({ y)
which can get out of hand quickly.
In the thread, we were looking for the nonzero values of y, so (4 $. $.)
is spot on.
Henry Rich
On 11/13/2020 10:54 PM
Another candidate is >,{i.&.>$x . (4 $. $.) has the "problem" that indices
corresponding to 0 elements are excluded.
On Fri, Nov 13, 2020 at 6:59 PM Henry Rich wrote:
> Ric Sherlock has suggested that (4 $. $.) would be an idiom worthy of
> special code. I agree & will do it sometime.
>
>
--
2
R.E. Boss
-Original Message-
From: Programming On Behalf
Of thomas.bulka via Programming
Sent: vrijdag 13 november 2020 18:05
To: programm...@jsoftware.com
Subject: [Jprogramming] Getting indices of matrix elements
Hi everyone,
still learning J, I stumbled across a problem which shou
3:00 PM, R.E. Boss wrote:
$.$.M
0 0 │ 1
0 1 │ 2
0 2 │ 3
0 3 │ 4
1 0 │ 5
1 1 │ 6
1 2 │ 7
1 3 │ 8
2 0 │ 9
2 1 │ 10
2 2 │ 11
2 3 │ 12
R.E. Boss
-Original Message-
From: Programming On Behalf
Of thomas.bulka via Programming
Sent: vrijdag 13 november 2020 18:05
To: program
1 │ 10
>>> 2 2 │ 11
>>> 2 3 │ 12
>>>
>>>
>>> R.E. Boss
>>>
>>>
>>> -Original Message-
>>> From: Programming On Behalf
>> Of thomas.bulka via Programming
>>> Sent: vrijdag 13 november 2020 18:05
>&g
yes, or as a verb
6 (4 $. $.@:=) i.4 3
2 0
On Friday, November 13, 2020, 01:04:39 p.m. EST, Ric Sherlock
wrote:
How about
4 $. $. 6=M
1 1
On Sat, 14 Nov 2020, 06:54 Hauke Rehr, wrote:
> plus, Henry’s solution looks more idiomatic (too me, at least)
>
> usually, I try to keep
E. Boss
> >
> >
> > -Original Message-
> > From: Programming On Behalf
> Of thomas.bulka via Programming
> > Sent: vrijdag 13 november 2020 18:05
> > To: programm...@jsoftware.com
> > Subject: [Jprogramming] Getting indices of matrix elements
> >
; >
> > R.E. Boss
> >
> >
> > -Original Message-
> > From: Programming On Behalf
> Of thomas.bulka via Programming
> > Sent: vrijdag 13 november 2020 18:05
> > To: programm...@jsoftware.com
> > Subject: [Jprogramming] Getting indices of matri
: Programming On Behalf Of
thomas.bulka via Programming
Sent: vrijdag 13 november 2020 18:05
To: programm...@jsoftware.com
Subject: [Jprogramming] Getting indices of matrix elements
Hi everyone,
still learning J, I stumbled across a problem which should be easy to solve,
but somehow I have not been
This topic has been discussed before:
http://www.jsoftware.com/pipermail/programming/2018-November/052287.html
Another way to learn is to study J Phrases, specially section 4.B.,
accessible through Help, Vocabulary, Phr.
~ Gilles
Le 2020-11-13 à 15:00, R.E. Boss a écrit :
$.$.M
0 0 │ 1
: [Jprogramming] Getting indices of matrix elements
Hi everyone,
still learning J, I stumbled across a problem which should be easy to solve,
but somehow I have not been able to do so, yet. Say, I have defined a matrix M:
M =: 3 4 $ >: i. 12
I now want to get the row and column index of 6 i
For me too - on my iPhone...
4 $. $. 6=3 4 $ >: i. 12
1 1
I’m bemused that no one has suggested the more j way of defining M
4 $. $. 6 = >: i. 3 4
1 1
Sent from my iPhone
> On Nov 13, 2020, at 10:31, Devon McCormick wrote:
>
> 4 $. $. 6=3 4 $ >: i. 12
---
13. Nov. 2020, 19:30 von devon...@gmail.com:
> Did you change "M"? It works fine for me.
>
> 4 $. $. 6=3 4 $ >: i. 12
> 1 1
>
Hi Devon,
my fault, you are completely right. I accidentally assigned another value to M
in the meantime and then was surprised by the result...
Regards,
Thomas
Did you change "M"? It works fine for me.
4 $. $. 6=3 4 $ >: i. 12
1 1
On Fri, Nov 13, 2020 at 1:22 PM 'Thomas Bulka' via Programming <
programm...@jsoftware.com> wrote:
> 13. Nov. 2020, 19:04 von tikk...@gmail.com:
>
> > How about
> >
> > 4 $. $. 6=M
> >
> > 1 1
> >
> Hi Ric,
>
> your sol
Wow. Just when I think I'm starting to get proficient in the language...
M (4 $. [: $. =) 6 32 58
0 1 1
1 2 2
2 3 3
This sparse array approach behaves differently from my proposal for an edge
condition (lookup not found):
M (4 $. [: $. ="_ 0~) 99 NB. Empty result for "not found"
13. Nov. 2020, 19:04 von tikk...@gmail.com:
> How about
>
> 4 $. $. 6=M
>
> 1 1
>
Hi Ric,
your solution yields the following:
4 $. $. 6=M
0 1 1
1 0 1
1 3 1
2 2 1
I cannot reproduce your result.
Regards,
Thomas
-
How about
4 $. $. 6=M
1 1
On Sat, 14 Nov 2020, 06:54 Hauke Rehr, wrote:
> plus, Henry’s solution looks more idiomatic (too me, at least)
>
> usually, I try to keep related structures aligned (using grade)
> other than that, I hardly remember any cases when linear indexing
> didn’t do the jo
This is a commonly recurring problem. One way to think of it is like this:
($M)#:(,M) i. 6
1 1
That is, rebase the position of the number you are looking up in the vector
as a mixed-base number where the base is the shape of the array. This
generalizes to multi-dimensional arrays:
M=: i. 3
plus, Henry’s solution looks more idiomatic (too me, at least)
usually, I try to keep related structures aligned (using grade)
other than that, I hardly remember any cases when linear indexing
didn’t do the job, maybe after some reduction
so I think in most cases this should not be needed
but if
13. Nov. 2020, 18:40 von programm...@jsoftware.com:
> Having seen Henry's solution, I see that I have left the job half done, so
> here is the rest of my solution.
>
> dyadind =. ;@:(= #"1 {@({@i."0 @$@]))
> 6 dyadind i. 3 4
> 1 2
>
> Having produced that, I note that Henry's is twice as fast a
Having seen Henry's solution, I see that I have left the job half done, so here
is the rest of my solution.
dyadind =. ;@:(= #"1 {@({@i."0 @$@]))
6 dyadind i. 3 4
1 2
Having produced that, I note that Henry's is twice as fast and takes up half
the space and the differences become more ap
Hi Thomas,
I usually use something like this which relies on Category ({) to group the
indices generated by i. applied to each index of the shape. I imagine others
have different approaches.
i. 3 4
0 1 2 3
4 5 6 7
8 9 10 11
ind=.{@({@i."0 @$)
ind i. 3 4
┌───┬───┬───┬───┐
│0 0│0 1│0
Actually, I don’t know either.
I just wove together something I think is way too much work
for this simple task:
+/@(* i.@#)"1 (+/ ,: +/"1) (6 E."0 1 M)
Any suggestions?
Am 13.11.20 um 18:05 schrieb thomas.bulka via Programming:
> Hi everyone,
>
> still learning J, I stumbled across a problem
6 ($@] #: I.@(= ,)) M
1 1
Henry Rich
On 11/13/2020 12:05 PM, thomas.bulka via Programming wrote:
Hi everyone,
still learning J, I stumbled across a problem which should be easy to solve,
but somehow I have not been able to do so, yet. Say, I have defined a matrix M:
M =: 3 4 $ >: i. 12
I
Hi everyone,
still learning J, I stumbled across a problem which should be easy to solve,
but somehow I have not been able to do so, yet. Say, I have defined a matrix M:
M =: 3 4 $ >: i. 12
I now want to get the row and column index of 6 in M, which is 1 2. If M was a
vector, I could easily ge
32 matches
Mail list logo