[Jprogramming] Return of max of list and it's index in single pass

'Jon Hough' via Programming programming at jsoftware.com
Wed Jan 25 02:58:20 UTC 2017


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


More information about the Programming mailing list