Index of max function


Author
Message
Andrew Papale
Andrew Papale
Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)
Group: Forum Members
Posts: 58, Visits: 205
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
Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)
Group: Forum Members
Posts: 58, Visits: 205
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
Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)
Group: Forum Members
Posts: 58, Visits: 205
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: 95K
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>