Output position of max within list

crollinson shared this question 4 years ago
Answered

I'm trying to figure out a way to output the POSITION within a list of a max/min.


Example: {3,2,13,2,6,8}


I'd like to know that 13 is the max (easy) and that it's in position 3.


Thanks for your help.

Comments (2)

photo
2

for list1={3,2,13,2,6,8} is a=Max[list1]

Then: IndexOf[a, list1]=4 gives you the position of this maximum value.

Shorter: IndexOf[Max[list1], list1]

chris


791efc2ee80145f04e26f7894a6598ed

photo
1

Thanks so much! That's exactly what I was looking for.


Here's the applet I was working on:

https://ggbm.at/AQdFBK5N


Now, when you click to show Δs, it shows the longest one which makes a nice sample triangle (unless it's really steep).


Thanks again,

Chip

© 2021 International GeoGebra Institute