Right, one can even get away with,

   13 : '((y i. M) , M) [ M=. <./ y'
] (i. , ]) <./

One reason I like tacit sentences is that, after some practice, one can
manipulate them easily.  So, the following are equivalent,

       {.@:I.@:(= >./),    >./  NB. Jon's verb
    ] ({.@:I.@:([ = ]), ]) >./
    ] ({.@:I.@:   =   , ]) >./
    ] (i.             , ]) >./) NB. The product of 13 : '((y i. M) , M) [
M=. <./ y'
      (i.             , ]) >./  NB. Raul's solution


On Wed, Jan 25, 2017 at 9:30 AM, Linda A Alvord <[email protected]>
wrote:

> Jon,  I haven't been using J for a while so I tried your problem. In a way
> I must think like a beginner again.  Here's my take after a false start
> where I used APL!
>
> [A=:?6#50
> 40 5 19 46 34 40
>    >/A
> 1
>    >./A
> 46
>
>
>    i.$A
> 0 1 2 3 4 5
>
>
>
>    A=>./A
> 0 0 0 1 0 0
>
>    i.$A
> 0 1 2 3 4 5
>       (A=>./A)    #i.$A
> 3
>
>    f=: 13 :'(y=>./y)#i.$y'
>    f A
> 3
>
>    f
> (] = >./) # [: i. $
>
>
> So this is "beginner Tacsit" that seems to work. Then it is fun to see
> what I can learn from the masters who have  already solved your problem.
> Keep sending your questions. They are goo for all of us.
>
> Linda
>
>
>
> -----Original Message-----
> From: Programming [mailto:[email protected]] On
> Behalf Of 'Jon Hough' via Programming
> Sent: Tuesday, January 24, 2017 11:29 PM
> To: [email protected]
> Subject: Re: [Jprogramming] Return of max of list and it's index in single
> pass
>
> Yep, that's what I was looking for. Thanks!
>
> --------------------------------------------
> On Wed, 1/25/17, Raul Miller <[email protected]> wrote:
>
>  Subject: Re: [Jprogramming] Return of max of list and it's index in
> single     pass
>  To: "Programming forum" <[email protected]>
>  Date: Wednesday, January 25, 2017, 12:01 PM
>
>     maxIndexAndValue=:
>  ((i.,]) >./)
>
>  I hope this
>  helps,
>
>  --
>  Raul
>
>
>  On Tue, Jan 24, 2017 at 9:58 PM, 'Jon
>  Hough' via Programming
>  <[email protected]>
>  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

Reply via email to