[Jprogramming] Indexing into array
Henry Rich
HenryHRich at nc.rr.com
Thu May 29 11:09:49 UTC 2014
It's in NuVoc:
http://www.jsoftware.com/jwiki/Vocabulary/curlylf#dyadic
Henry Rich
On 5/29/2014 6:44 AM, alexgian wrote:
> Oops, scratch that, just saw it.
>
>
> On 29 May 2014 11:39, alexgian <alexgian at blueyonder.co.uk> wrote:
>
>> Thanking you kindly, sir, that's a relief!
>> Seems to work at all ranks, too.
>> I don't think it's in the Voc (under { ), or my eyesight is getting really
>> bad. Should be, IMHO, fairly crucial thing for an array-programming
>> language.
>>
>>
>>
>> On 29 May 2014 11:23, Kip Murray <thekipmurray at gmail.com> wrote:
>>
>>> i. 4 4
>>> 0 1 2 3
>>> 4 5 6 7
>>> 8 9 10 11
>>> 12 13 14 15
>>> (<2 1) { i. 4 4
>>> 9
>>>
>>>
>>> On Thursday, May 29, 2014, alexgian <alexgian at blueyonder.co.uk> wrote:
>>>
>>>> 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.
>>>> ----------------------------------------------------------------------
>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>>
>>>
>>>
>>> --
>>> Sent from Gmail Mobile
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>
>>
>>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
More information about the Programming
mailing list