The original request was for code that did only one search through the input list. Using (\:), or even both (<./) and (i.) separately, passes over the input more than once.

Henry Rich

On 1/25/2017 6:05 PM, Linda A Alvord wrote:
Your idea but fewer parentheses

([: {. \:) , >./

Linda


-----Original Message-----
From: Programming [mailto:[email protected]] On Behalf 
Of R.E. Boss
Sent: Wednesday, January 25, 2017 10:51 AM
To: [email protected]
Subject: Re: [Jprogramming] Return of max of list and it's index in single pass

((],{~) {.@\:)


R.E. Boss

-----Original Message-----
From: Programming [mailto:[email protected]] On Behalf 
Of Henry Rich
Sent: woensdag 25 januari 2017 11:15
To: [email protected]
Subject: Re: [Jprogramming] Return of max of list and it's index in single pass

Oh, then

((] , {~) (i. >./))

Henry Rich


On 1/24/2017 11:28 PM, 'Jon Hough' via Programming wrote:
Thanks for the reply, but
   (i. >./) 2 3 4 2 3 1 gives me only the index of the max element.

I would like the index and value pair returned. It seems Raul solved it.

Thanks again,
Jon
--------------------------------------------
On Wed, 1/25/17, Henry Rich <[email protected]> wrote:

   Subject: Re: [Jprogramming] Return of max of list and it's index in single 
pass
   To: [email protected]
   Date: Wednesday, January 25, 2017, 12:02 PM
(i. >./) From section 1.6.6 of
   http://code.jsoftware.com/wiki/Vocabulary/SpecialCombinations
Henry Rich On 1/24/2017 9:58 PM, 'Jon Hough' via
   Programming wrote:
   > I want to get the
   max value of a list, and return the first index of its
   occurrence in the list, tacitly.
   >
   > My solution
   >
   >   maxWithIndex =: {.@:I.@:(=
   >./), >./
   >
   >
   works ok, but calculates >./ twice. Is there a tacit way
   to do this with only a single calc of >./ ?
   >
   > Thanks,
   > Jon
   >
   ----------------------------------------------------------------------
   > For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
   For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

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