[Jprogramming] index of maximum value

Randy MacDonald ramacd at nbnet.nb.ca
Fri Oct 17 08:13:07 HKT 2008


Hello Don;

Neat solution, which probably scans the array (log N) times, being a 
sort and all.

Don Guinn wrote:
> How about
> {.\: ?. 30$100
> 9
>
>
> On Sun, Oct 12, 2008 at 9:00 AM, June Kim <juneaftn at gmail.com> wrote:
>
>   
>> I can get the index of the maximum value easily, first getting the
>> maximum and then getting the index:
>>
>>   I.@(=>./) ?. 30$100
>> 9
>>
>> Suppose, there is one presence of maximum value in the data.
>>
>> However, the solution isn't satisfactory to me. Is there a simple
>> single step way of finding the index of the max? That is, the way
>> where you don't need to scan the data twice(once for max, another for
>> index).
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>>     
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
>   

-- 
------------------------------------------------------------------------
|\/| Randy A MacDonald       | APL: If you can say it, it's done.. (ram)
|/\| ramacd <at> nbnet.nb.ca |
|\ |                         | The only real problem with APL is that
BSc(Math) UNBF'83            | it is "still ahead of its time."
Sapere Aude                  |     - Morten Kromberg
Natural Born APL'er          |
-----------------------------------------------------(INTP)----{ gnat }-





More information about the Programming mailing list