nice.

   Ginx=: _2 <\ ;/ 
   (Ginx 2 3 0 5 1 2) {i.5 6 
15 5 8 



----- Original Message -----
From: Nollaig MacKenzie <[email protected]>
To: [email protected]
Cc: 
Sent: Thursday, May 29, 2014 1:27:46 PM
Subject: Re: [Jprogramming] Indexing into array

I use

Ginx=: <"0&.>@<"1

    (Ginx 2 2$1 2 2 3){i.3 5
7 13


On 2014.05.29 11:15:22, you,
the extraordinary alexgian, spake thus:

> If I want to index into a (rank 2) array to get the element usually called
> the (i,j)th in the big, bad world, is there a better way to do it than
> this, which I currently use?
> 
>     idx  =: (1 { [) { ] {~ 0 { [
> 
>     2 1 idx 4 4 $i.16
> 
> 9
> 
> I notice that if { takes an array as left arg, it merely returns the given
> rows of that array, rather than the required indexed element.
> So I can't do, for instance,  (2 1) { 4 4 $i.16 and get what I want
> Furher, I wander if there is a more generic way of writing this so that it
> would work automatically for rank-3 arrays and greater.

-- 
Nollaig MacKenzie
http://www.yorku.ca/nollaig



----------------------------------------------------------------------
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