Index of max function


Author
Message
Andrew Papale
Andrew Papale
Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)
Group: Forum Members
Posts: 62, Visits: 230
Dear Inquisit Team,

What is the best way to find the index of a value in the max function?

i.e. index of max(4,0,1,3,2) would return 2, index of max(2,3,4,1,5) would return 4.

I feel like there might be a way to do this with lists:  https://www.millisecond.com/support/docs/current/html/language/functions/indexof.htm


Thanks,
Andrew

Andrew Papale
Andrew Papale
Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)
Group: Forum Members
Posts: 62, Visits: 230
Andrew Papale - 10/2/2023
Dear Inquisit Team,

What is the best way to find the index of a value in the max function?

i.e. index of max(4,0,1,3,2) would return 1, index of max(2,3,4,1,5) would return 5.

I feel like there might be a way to do this with lists:  https://www.millisecond.com/support/docs/current/html/language/functions/indexof.htm


Thanks,
Andrew

Not sure how to edit, but obviously the examples I gave would be for the min function.  For the max, we would return 1 and 5, respectively, thanks
Andrew Papale
Andrew Papale
Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)Partner Member (815 reputation)
Group: Forum Members
Posts: 62, Visits: 230
Andrew Papale - 10/2/2023
Andrew Papale - 10/2/2023
Dear Inquisit Team,

What is the best way to find the index of a value in the max function?

i.e. index of max(4,0,1,3,2) would return 1, index of max(2,3,4,1,5) would return 5.

I feel like there might be a way to do this with lists:  https://www.millisecond.com/support/docs/current/html/language/functions/indexof.htm


Thanks,
Andrew

Not sure how to edit, but obviously the examples I gave would be for the min function.  For the max, we would return 1 and 5, respectively, thanks

This solution seems to work for values <=5 but is not general to any integer N without N if else statements.

<list best>
/ items = (values.rem0, values.rem1, values.rem2, values.rem3, values.rem4, values.rem5)
/ poolsize = 6
/ selectionrate = always
</list>


Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 100K
Andrew Papale - 10/2/2023
Andrew Papale - 10/2/2023
Andrew Papale - 10/2/2023
Dear Inquisit Team,

What is the best way to find the index of a value in the max function?

i.e. index of max(4,0,1,3,2) would return 1, index of max(2,3,4,1,5) would return 5.

I feel like there might be a way to do this with lists:  https://www.millisecond.com/support/docs/current/html/language/functions/indexof.htm


Thanks,
Andrew

Not sure how to edit, but obviously the examples I gave would be for the min function.  For the max, we would return 1 and 5, respectively, thanks

This solution seems to work for values <=5 but is not general to any integer N without N if else statements.

<list best>
/ items = (values.rem0, values.rem1, values.rem2, values.rem3, values.rem4, values.rem5)
/ poolsize = 6
/ selectionrate = always
</list>